Travis CI: npm install ERESOLVE


Travis CI

I received an npm install error for my Travis CI build after upgrading my dependencies:

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @rollup/plugin-typescript@2.1.0
npm ERR! node_modules/@rollup/plugin-typescript
npm ERR!   dev @rollup/plugin-typescript@"^6.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @rollup/plugin-typescript@"^6.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: rollup@2.33.1
npm ERR! node_modules/rollup
npm ERR!   peer rollup@"^2.14.0" from @rollup/plugin-typescript@6.1.0
npm ERR!   node_modules/@rollup/plugin-typescript
npm ERR!     dev @rollup/plugin-typescript@"^6.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/travis/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2020-11-08T01_13_40_933Z-debug.log

This started happening with npm v7 and I realized it’s related to build cache:

Setting up build cache

$ node --version
v15.1.0
$ npm --version
7.0.8
$ nvm --version
0.36.0

So I ended up disabling npm cache in .travis.yml to get a green build:

# .travis.yml
cache:
  npm: false

Local

To fix this error locally, delete node_modules and reinstall:

$ rm -rf node_modules && npm i


Please support this site and join our Discord!