> ## Content Index
> Fetch the complete content index at: https://danielbarta.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# How to Avoid Angular CLI Caching When Debugging npm linked Libraries
- URL: https://danielbarta.com/avoid-caching-local-libraries-during-angular-build/
- Published: 2025-05-25T12:00:12.000Z
- Updated: 2026-06-22T01:17:17.000Z
- Description: I ran into an issue that slowed me down: when serving the app, Angular CLI’s build cache was preventing updates to the JS and WASM files from being picked up. The build reused a cached version, which meant I couldn’t test changes without restarting or clearing the cache manually.
- Author: Daniel Barta
- Tags: Angular, Today I Learned, #Import 2026-10-23 10:14

For the past few months, I’ve spent most of my time working on a JS/WASM npm package. When I need to debug its integration in an Angular app, I use `npm link` to bring it into `node_modules`. However, I ran into an issue that slowed me down: when serving the app, Angular CLI’s build cache was preventing updates to the JS and WASM files from being picked up. The build reused a cached version, which meant I couldn’t test changes without restarting or clearing the cache manually.

This caching is generally a great feature, for regular Angular development tasks, it speeds things up. But in this context, it became a bottleneck.

Initially, I thought the only solution was to disable caching via `ng cache disabled` or directly in the `angular.json`. While that worked, the build became significantly slower, and toggling the flag each time was cumbersome. I even opened a feature request to Angular CLI asking for a way to disable cache on demand. Fortunately, [@alan-agius4 pointed out a simpler solution](https://github.com/angular/angular-cli/issues/30308?ref=danielbarta.com#issuecomment-2887253905).

```json
"serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
        "prebundle": {
            "exclude": ["lib"]
        }
    }
}
```

The feature I needed is actually well-documented. Pre-bundling is an optimization step in Angular (which uses Vite under-the-hood), and excluding my library from this step solved the issue with minimal impact on performance.

Once I knew what to search for, I quickly found a relevant [answer on StackOverflow](https://stackoverflow.com/a/79117979?ref=danielbarta.com) and a good description in the [documentation](https://angular.dev/tools/cli/build-system-migration?ref=danielbarta.com#prebundling).

> The prebundling process analyzes all the third-party project dependencies within a project and processes them the first time the development server is executed. This process removes the need to rebuild and bundle the project's dependencies each time a rebuild occurs or the development server is executed.

I had checked the schema of the `angular.json`, and searched for solutions. I just failed to connect the dots this time. It’s a good reminder to keep on doing my own research first, but also not to be afraid of questioning the default behavior. Even if I’m wrong, I can learn from it.

[Allow disabling CLI cache in \`ng serve\` via command-line flag · Issue #30308 · angular/angular-cliCommand serve Description Currently, the recommended way to disable the Angular CLI cache is via ng cache enable and ng cache disable, which modifies the cli.cache.enabled setting in angular.json.…![](https://github.com/fluidicon.png)GitHubangular![](https://opengraph.githubassets.com/96f022fd2338575aa53d80f74260b538acd915a174215367e7fb3e6d675ded8b/angular/angular-cli/issues/30308)](https://github.com/angular/angular-cli/issues/30308?ref=danielbarta.com#issuecomment-2889102564)

[AngularThe web development framework for building modern apps.![](https://angular.dev/assets/icons/apple-touch-icon.png)Angular![](https://angular.dev/assets/images/ng-image.jpg)](https://angular.dev/tools/cli/build-system-migration?ref=danielbarta.com#prebundling)