Locally installed packages are cached via:
# .travis.yml
...
cache:
directories:
- node_modules
...
But how do I cache globally installed packages ($ npm install -g <...>
) to speed up my builds?
This is how I did it:
cache:
directories:
# Replace "grunt-cli" with whatever global binary you're using
- $(npm config get prefix)/bin/grunt-cli
EDIT:
As was pointed out in the comments, $(npm config get prefix)/bin
contains symlinks to other code. This is untested but would probably work: $(npm config get prefix)/lib/node_modules
. That should cache all globally installed modules.
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