Home > Enterprise >  npm i conflict issue after update my nodejs
npm i conflict issue after update my nodejs

Time:07-31

I upgraded my node from 14 to 16; and faced this problem while doing npm i, see screenshot to see the problem:

terminal screenshot

I have tried to remove node modules, clearing cache, doing npm i again; didn't help.

Also tried doing npm i --legacy-peer-deps

How can I resolve such dependency conflicts?

CodePudding user response:

The error message itself tells you what the problem is and how you might be able to solve it.

You have [email protected] installed which has node-sass@^4.0.0 as a peer dependency. But in your root project you have node-sass@^7.0.1 installed.

If you look at the sass-loader changelog, you can see that they added support for node-sass v7 in v12.4.0.

So, your solution seems to be either upgrade sass-loader to v12.4.0 or later (v13.0.2 is the latest), or downgrade node-sass to v4.x.x.

If you run into other problems, the node-sass GitHub page has a troubleshooting guide at https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md.

Node v16 comes bundled with a newer version of npm, so your problem most likely stems not from the node version upgrade per se, but from an npm upgrade. From https://github.blog/2021-02-02-npm-7-is-now-generally-available/#peer-dependencies (emphasis mine):

Automatically installing peer dependencies is an exciting new feature introduced in npm 7. In previous versions of npm (4-6), peer dependencies conflicts presented a warning that versions were not compatible, but would still install dependencies without an error. npm 7 will block installations if an upstream dependency conflict is present that cannot be automatically resolved.

To help further troubleshoot this, it would be helpful to know the exact version of node (node --version) and npm (npm --version) you are running, as well as the contents of your package.json and your lockfile (package-lock.json). Although the above info should be enough for you to know why this error occurred (npm v7 breaking change) and what you can do to solve it (upgrade sass-loader).

  • Related