问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/30240237/how-do-i-cache-global-npm-packages-on-travis-ci