Unable to resolve dependency tree error when installing npm packages

别来无恙 提交于 2020-12-29 03:45:13

问题


When trying to install the npm packages using npm i command I am getting the following exception:

I have tried reinstalling the node js package and setting proxy to off using:

set HTTP_PROXY=
set HTTPS_PROXY=

The issue is still there. What I am doing wrong?

Update:

When I run the following command:

npm install --legacy-peer-deps

The following error is displayed:


回答1:


This is not related to http proxy.

You have dependency conflict (incorrect and potentially broken dependency) as it says, So try to to run the command with --force, or --legacy-peer-deps. If it doesn't take effect, the temporary solution is using prior versions of the node (Downgrading node version) as it causes to happen such this errors sometimes.

Update based on OP's Update:

As you see, it fires the following error :

No matching version found for @angular/http@^9.1.4.

Take a look at angular/http page. Note that the latest version for that deprecated package is 7.2.16 while you request an upper version (e.g ^9.1.4)! So, try to check the project dependencies and follow the raised errors in order to solve the problem.




回答2:


When using npm 7, I have experienced this when working with a node_modules/package-lock.json generated with npm 6. Usually using --legacy-peer-deps makes it work.

When that doesn't work, an option is to downgrade to npm 6. Downgrading Node.js is not necessary (but not harmful either). The relevant dependency management code is in npm. Downgrading Node.js will often work coincidentally because doing so will often downgrade npm as well.

Another option that is less disruptive than downgrading npm is using npx to use the previous version of npm for just the install command: npx -p npm@6 npm install

And when all else fails, it's often worth a shot to remove the node_modules directory and package-lock.json, and then run npm install again. That regenerates node_modules and package-lock.json.




回答3:


Try removing the node modules and package-lock.json file and run command npm install or Try npm cache clean --force




回答4:


Try this command-

npm install --save --legacy-peer-deps



回答5:


The problem seems to be that gf-kautomata-pipeline-ui is using Angular 9, while @angular/http requires Angular 7. (@angular/http was deprecated and eventually removed, and all its functionality was moved into @angular/common instead.)

See: https://www.npmjs.com/package/@angular/http

If you're running Angular 9, then

  1. delete @angular/http from your package.json (You don't need it in Angular 9)

  2. Make sure you have @angular/common in your package.json.

  3. Run npm i.

If you're running Angular 7, then open up your package.json and check to make sure all of your Angular packages are no higher than ^7.0.0. You may also need remove gf-kautomata-pipeline-ui, or contact the author of gf-kautomata-pipeline-ui and find out if the library is compatible with Angular 7.




回答6:


please install the LTS version of node which are recommended by most users it helps me a lot to save my life



来源:https://stackoverflow.com/questions/64573177/unable-to-resolve-dependency-tree-error-when-installing-npm-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!