Trying to npm install vue-mapbox mapbox-gl and I'm getting a dependency tree error.
I'm running Nuxt SSR with Vuetify, and haven't installed anything related to Mapbox prior to running this install and getting this error.
38 error code ERESOLVE 39 error ERESOLVE unable to resolve dependency tree 40 error 41 error While resolving: [1mexample[22m@[1m1.0.0[22m 41 error Found: [1mmapbox-gl[22m@[1m1.13.0[22m[2m[22m 41 error [2mnode_modules/mapbox-gl[22m 41 error [1mmapbox-gl[22m@"[1m^1.13.0[22m" from the root project 41 error 41 error Could not resolve dependency: 41 error [35mpeer[39m [1mmapbox-gl[22m@"[1m^0.53.0[22m" from [1mvue-mapbox[22m@[1m0.4.1[22m[2m[22m 41 error [2mnode_modules/vue-mapbox[22m 41 error [1mvue-mapbox[22m@"[1m*[22m" from the root project 41 error 41 error Fix the upstream dependency conflict, or retry 41 error this command with --force, or --legacy-peer-deps 41 error to accept an incorrect (and potentially broken) dependency resolution. 41 error 41 error See /Users/user/.npm/eresolve-report.txt for a full report. 42 verbose exit 1 What's the right way to go about fixing this upstream dependency conflict?
10 Answers
Looks like it's a problem with Peer Dependencies in the latest version of npm (v7) which is still a beta version. try with npm install --legacy-peer-deps for detail info check this
Use --legacy-peer-deps after npm install. For example, if you want to install radium, use:
npm install --legacy-peer-deps --save radium There are TWO ways:
use
npm install --legacy-peer-depsto install, and if this doesn't work useforce method. add --force next to npm install:
npm install --force
until npm version 7.19.1 still have same issue, after upgraded to version 7.20.3 use command npm install -g npm@latest and npm audit fix all pkgs fixed without error.
You can follow this command
first type:
npm config set legacy-peer-deps true then type:
npx create-react-app my-app 1To Solve Fix the upstream dependency conflict installing NPM packages Error
Method 1. Just Use --legacy-peer-deps after npm install.
For example, if you want to install axios, use
npm install --legacy-peer-deps --save axios. Method 2. Updating npm and audit fix
npm I -g npm@latest npm audit fix --force Method 3. using --force to install packages
npm install axios --force - delete the package-lock.json file
- modify the package.json , updating the version as indicated by the peer dependancy
- run npm install or npm udpate
I tried multiple ways but nothing was working for me. At last tried this and it worked npm config set legacy-peer-deps true Run this in the project folder and then try to install any package. Might work for you as well
I have downgraded my node version to 10.23.1 it worked fine.
A lot of upvotes for using --legacy-peer-deps but if --force works I would recommend using that since it still pins many dependency versions while --legacy-peer-deps ignore peer dependencies entirely. See example below:
Started getting this error on Azure DevOps a few days ago. Initially thought it was a glitch on Azure side but since it continued we started looking into it a bit more.
Turns out the agent we are using, windows-2022, was updated a few days ago.
Node and NPM now match the Latest Node.js LTS Version: 16.15.1 (includes npm 8.11.0)
You can view all agents included Software here:
After reading on Microsoft Visual Studio Developer Community they recommend downgrading Node.js using Node.js Tool Installer task like this:
- task: NodeTool@0 inputs: versionSpec: '16.14.2' However we decided that we do not want to downgrade Node.js so first step was matching Node.js locally with LTS Version: 16.15.1 and npm 8.11.0.
When running npm ci we then got the same error locally.
Tried npm ci --force and we then got this error:
npm cican only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file withnpm installbefore continuing.
npm install gave the same error even after node_modules was manually removed but npm install --force worked and it generated a new package-lock.json.
npm ci still failed with the same error but running npm ci --force worked. We decided to update Azure DevOps .yml to include --force and checked in the new package-lock.json. After doing this everything works like before and we can now update our packages one by one.