Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable npm cache

Tags:

Some time ago I had trouble with the npm cache on our build machines. From time to time we had to do npm cache clean by hand, and that solved various issues that we are still not certain about what caused them. So after a time we included npm cache clean in all our build scripts, since then we did not have mysterious problems with npm i, however now parallel builds obviously affect each other.

For me the best solution seems to be completely turn off the npm caching mechanism, but I couldn't find out how to do that.

like image 443
Tamas Hegedus Avatar asked Mar 22 '16 13:03

Tamas Hegedus


2 Answers

You could fix the problem with parallel builds by creating a new directory for one series of npm commands and set its cache to that empty directory and then remove that directory afterwards. Like:

export npm_config_cache=$(mktemp -d)  npm ... ... rm -rf $npm_config_cache 

This would remove the need for npm cache clean as it would always start out with an empty cache.

like image 121
Dan D. Avatar answered Oct 19 '22 09:10

Dan D.


As npm-config documented:

force§ Default: false Type: Boolean Makes various commands more forceful.

  1. lifecycle script failure does not block progress.
  2. publishing clobbers previously published versions.
  3. skips cache when requesting from the registry.
  4. prevents checks against clobbering non-npm files.

Maybe use -f / --force is the simplest way to disable npm cache.

npm install --force 
like image 24
nilptr Avatar answered Oct 19 '22 10:10

nilptr