39

From version 13.0.0 there will be a .angular folder generated in root which is ignored by git containing a cache folder which caches builds.

How can I remove (or clear) this cache?

Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
  • 4
    Not 100% relevant to the question, but perhaps still useful for others, I upgraded from Angular 12 to 13 and manually had to add `.angular` to my `.gitignore` - it was not added for me. – fullStackChris Dec 15 '21 at 13:06
  • That's weird... Mine added automatically. @fullStackChris – Mahdi Zarei Dec 15 '21 at 13:26

2 Answers2

76

You can configure caching options of cli in angular.json file. One of options is cache which gives you the option of disabling it.

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "cache": {
      "enabled": false
    }
  },
  "projects": {}
}

You can disable it by running this command too:

ng config cli.cache.enabled false
  • To clear the cache on Unix-based operating systems:
rm -rf .angular/cache
  • To clear the cache on Windows:
rmdir /s /q .angular/cache

Update (10th, Aug 2022):

For Angular 14 and up, you can now clear, enable and disable cache config by running these commands:

clean

ng cache clean

// Deletes persistent disk cache from disk.

disable

ng cache disable
ng cache off

// Disables persistent disk cache for all projects in the workspace.

enable

ng cache enable
ng cache on

You can find out more about it in docs.

PVermeer
  • 2,631
  • 2
  • 10
  • 18
Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
  • Deleting the /.Angular/Cache/ directory (like the command "rmdir" is doing) worked for me! I'm specifically calling out that rmdir deletes the directory, incase anybody glosses over this. – majestzim Apr 19 '23 at 14:14
7

To clear the Angular cache you can run:

ng cache clean
bargz
  • 153
  • 2
  • 4