When building our node application, we are using .npm cache as follows:
npm install --cache /tmp/node-cache/.npm --prefer-offline
However I have reasons to believe, the cache is not working properly as:
/tmp/node-cache/ # du -sh .npm/
177M .npm/
/tmp/build/ # du -sh node_modules/
1.1G node_modules
Does this mean the build downloaded additional 900 M and not caching them in .npm directory?
Does this mean the build downloaded additional 900 M and not caching them in .npm directory?
That's possible. But it's also possible that the difference is due to a combination of compression and build artifacts.
The npm cache is compressed. node_modules directories are uncompressed.
Furthermore, npm almost certainly only caches the source code. If you are using something like node-sass, PhantomJS, puppeteer, or some other thing that has a custom install script or other build step, then build artifacts may balloon your node_modules.
I would not necessarily conclude merely from the size difference that the cache is not being respected. You'll have to do more investigation. One thing you might try is:
node_modules (and package-lock.json if it exists)npm cache clean --force and confirm that the cache is very smallnpm installnode_modules and the cache again.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