Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I cache global NPM packages on Travis CI?

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?

like image 675
Jace Browning Avatar asked May 14 '15 14:05

Jace Browning


1 Answers

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.

like image 81
tandrewnichols Avatar answered Sep 28 '22 03:09

tandrewnichols