How do I cache global NPM packages on Travis CI?

半腔热情 提交于 2019-12-21 07:18:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!