Home > Back-end >  How to solve dependency conflict with NPM
How to solve dependency conflict with NPM

Time:06-18

I am trying to install all npm package I needed for the aws sample demo https://github.com/aws-samples/amazon-chime-sdk-classroom-demo in my laptop. But always get the similar error when I want to run

npm install 

I'm a bit curious if it's because I just got my so I've got the wrong npm and node version

The error code shows that

npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @typescript-eslint/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^8.4.1" from the root project
npm ERR!   peer eslint@"*" from @typescript-eslint/[email protected]
npm ERR!   node_modules/@typescript-eslint/experimental-utils
npm ERR!     @typescript-eslint/experimental-utils@"2.34.0" from @typescript-eslint/[email protected]
npm ERR!     node_modules/@typescript-eslint/eslint-plugin
npm ERR!       dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!       1 more (eslint-config-airbnb-typescript)
npm ERR!     @typescript-eslint/experimental-utils@"2.34.0" from @typescript-eslint/[email protected]
npm ERR!     node_modules/@typescript-eslint/parser
npm ERR!       dev @typescript-eslint/parser@"^2.17.0" from the root project
npm ERR!       2 more (@typescript-eslint/eslint-plugin, eslint-config-airbnb-typescript)
npm ERR!     1 more (eslint-plugin-jest)
npm ERR!   7 more (babel-eslint, eslint-config-prettier, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/[email protected]
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!   peer @typescript-eslint/eslint-plugin@"^2.7.0" from [email protected]
npm ERR!   node_modules/eslint-config-airbnb-typescript
npm ERR!     dev eslint-config-airbnb-typescript@"^6.3.1" from the root project
npm ERR!     1 more (eslint-config-erb)
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/[email protected]
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!     peer @typescript-eslint/eslint-plugin@"^2.7.0" from [email protected]
npm ERR!     node_modules/eslint-config-airbnb-typescript
npm ERR!       dev eslint-config-airbnb-typescript@"^6.3.1" from the root project
npm ERR!       1 more (eslint-config-erb)
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 /Users/liycheng/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/liycheng/.npm/_logs/2022-06-18T00_11_27_159Z-debug-0.log


my node version and npm version are:

$ npm -v
8.9.0
$ node -v
v18.2.0

I tried to solve dependency conflict by

npm install --legacy-peer-deps

but it's not working

CodePudding user response:

The demo was built using yarn as a package manager - so I would suggest you use yarn instead of npm to build and run your application.

npm install --global yarn
yarn install
yarn start

If it works, the reason for you npm installation failing is most likely some additional information on dependencies stored in the yarn.lock file that is not evaluated when building with npm.

CodePudding user response:

Above, you mentioned project repository consists yarn.lock file and doesn't consist package-lock.json. More than that inside the package.json there are many yarn commands defined. So the above project is initiated with yarn. So you need to use yarn commands instead of npm.

For that first check if you have yarn installed in your machine or not. using yarn check. If not installed then install yarn using npm install --global yarn. Then using yarn install --immutable --immutable-cache --check-cache do a clean install. It is a similar command to npm ci when you use npm.

To learn more about yarn check yarn doc

  • Related