I am trying to npm install
but getting this error.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: webapp@21.0.0
npm ERR! Found: @angular/cdk@9.2.4
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"9.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/cdk@"8.2.3" from @angular/material@8.2.3
npm ERR! node_modules/@angular/material
npm ERR! @angular/material@"8.2.3" 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.
I updated node.js to the latest recommended LTS version which is currently version 14. This is what is causing the problem.
I tried using --force
and --legacy-peer-deps
, but this didn't work.
The solution is to downgrade the node version to 12.
Here is a copy/paste solution to fix. Copy all of this code and paste in the terminal at the root of your project. (Where your package.json
file that you are trying to install is.)
rm package-lock.json
rm -rfv node_modules
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 12
nvm use 12
npm i
What is happening here?
package-lock.json
filenode_modules
directory ( -rfv
= recursive, force, verbose)nvm
(Node Version Manager)nvm
nvm
nvm
to install node v12npm
to install the packagestry npm install --legacy-peer-deps
. This worked for me. But first make sure you delete your package-lock.json
and node_modules
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.