How do I cache global NPM packages on Travis CI?

Jace Browning

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?

tandrewnichols

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I view the size of npm packages?

Should I have Travis cache node_modules or $HOME/.npm

Cache Brew builds with travis ci

How do I use Travis-CI with C# or F#

Cache gradle dependencies, Travis CI

Travis-CI: how to cache composer executable between builds?

How do travis-ci and gitlab-ci compare?

How do I cache 'pip install' packages on CircleCI?

Travis CI, update CMake using the packages cache

How do I deploy nuget packages in Travis CI?

How to run npm scripts from global packages?

How to cache packages which have been installed via `apt-get` in Travis CI?

How do I prevent npm install from removing packages?

How to npm audit global packages

How do I build Python 3.8 on Travis CI?

How to set up Travis CI to use linked (local) packages?

Can't find globally installed npm packages in Travis ci

Travis CI: How do I escape my password for `travis encrypt` to work?

How do I publish a private npm package with gitlab ci?

How do i use npm installed packages in my .js files?

How to ignore npm run errors and keep going on Travis-CI?

How do I run Unit Tests for .NET Framework 4.7 with Travis-CI?

How to use different R versions to test packages with Travis-CI?

How do I automatically deploy from Travis CI with the container-based infrastructure?

How do I cache packages for a snapcraft cleanbuild?

How do I integrate travis ci with codeclimate test coverage in Python?

How can I unset this command "npm config set cache "C:/Users/ASIMIM/AppData/Roaming/npm-cache" --global"

Fetching NPM global packages

How do I load NPM packages in browser dev tools console?