DEV Community

Discussion on: Setup Continuous Integration with Travis CI in Your Nodejs App

Collapse
 
hankchanocd profile image
Hank Chan • Edited

Note npm ci is now the default npm install mechanism instead of npm install

Since npm ci strictly adheres to the dependencies list on package-lock.json, it removes node_modules that may be installed using package.json before it begins its own installs. This way the cached modules and npm commands from the old cache location node_modules won't work. Therefore, travis will throw an error complaining "cannot find /node_modules/.bin/npm" after running npm ci.

There are two solutions to this problem:

  1. Fully transition to npm ci, and keep the npm cache at new location to speed up installs
cache:
  directories:
  - "$HOME/.npm"
  1. Specify to use old install, and continue to use the old cache location
install:
  - npm install
cache:
  directories:
    - "node_modules"

According to doc and some benchmark tests, npm ci is introduced to ensure proper build with package-lock.json and have build time twice faster than npm install, boosting your Travis build speed.
See here docs.npmjs.com/cli/ci