Alexander Mills
Alexander Mills

Reputation: 100010

Caching npm version on TravisCI

I have this travis.yml file:

language: node_js
node_js:
  - '8'
  - '7'
  - '6'
env:
  - CXX=g++-4.8
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8

before_install: 'if [[ `npm -v` != 4* ]]; then npm i -g npm@4; fi'
install:
  - npm install

Everytime a new build starts, it begins with NPM version 3, and so in the before_install hook, I upgrade the NPM version (4 works better than 5 for me).

Is there is a configuration I can use, which will cache the NPM 4 version, so I don't have to update it every time? I don't really want to cache other dependencies, if I can avoid it.

Upvotes: 0

Views: 63

Answers (1)

StephenG
StephenG

Reputation: 2881

how about caching the node_modules folder?

cache:
  directories:
  - node_modules # NPM packages
  - /usr/local/lib/node # cache globals as well
  - /usr/local/lib/node_modules

Upvotes: 1

Related Questions