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.
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.
As npm-config documented:
force§ Default: false Type: Boolean Makes various commands more forceful.
- lifecycle script failure does not block progress.
- publishing clobbers previously published versions.
- skips cache when requesting from the registry.
- prevents checks against clobbering non-npm files.
Maybe use -f
/ --force
is the simplest way to disable npm cache.
npm install --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With