"npm ci" will fail if cached dependency includes npm

Travis is failing when running npm ci if a previous build had installed npm as a dependency, in this case semantic-release/npm, as ./node_modules/.bin is added to $PATH and so it’ll attempt to use ./node_modules/.bin/npm which gets deleted as the first part of npm ci.

My expected behavior would be to use the npm that was installed as part of nvm and not the one installed in the repo, especially if using npm ci.

Example Job: https://travis-ci.com/MasterOdin/node-sdk/jobs/215760973

Here’s a job with some more explicit echos and such to show what’s going on: https://travis-ci.com/MasterOdin/node-sdk/jobs/215823658, namely:

$ which npm

$ npm ci || true
npm WARN prepare removing existing node_modules/ before installation
npm ERR! Cannot find module './fetchers/version'
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2019-07-13T19_58_08_209Z-debug.log

$ cat /home/travis/.npm/_logs/*
0 info it worked if it ends with ok
1 verbose cli [ '/home/travis/.nvm/versions/node/v6.17.1/bin/node',
1 verbose cli   '/home/travis/build/MasterOdin/node-sdk/node_modules/.bin/npm',
1 verbose cli   'ci' ]
2 info using npm@6.10.1
3 info using node@v6.17.1
1 Like

Are you using docker in travis?