当尝试使用npm i命令安装npm包时,我得到了以下异常:
我尝试重新安装Node.js包,并使用以下方法将代理设置为关闭:
set HTTP_PROXY=
set HTTPS_PROXY=
问题仍然存在。我哪里做错了?
更新:
执行以下命令时:
npm install --legacy-peer-deps
系统显示如下错误:
当尝试使用npm i命令安装npm包时,我得到了以下异常:
我尝试重新安装Node.js包,并使用以下方法将代理设置为关闭:
set HTTP_PROXY=
set HTTPS_PROXY=
问题仍然存在。我哪里做错了?
更新:
执行以下命令时:
npm install --legacy-peer-deps
系统显示如下错误:
当前回答
最快的解决方案:npm install——legacy-peer-deps
解释:
在npm版本3到6中,peerDependencies不会自动安装,如果在树中发现无效的peer dependency版本,将会发出警告。从npm v7开始,默认安装了peerDependencies。 npm docs: peerDependencies
你的依赖包含一些peerDependencies,这些peerDependencies与根项目的依赖冲突。
正如npm ERR日志中描述的那样。
其他回答
我只是更新了我的Node.js,它为我工作:
node -v
输出:
V xxxx
And:
sudo npm install -g n
(使用此命令安装稳定节点release)
sudo n stable
尝试删除节点模块和包锁。Json文件,运行命令NPM install 或 试试npm cache clean——force
我们有同样的问题,导致错误如下:
npm犯错!代码erresolve npm 犯错!erresolve无法解析npm 犯错! npm犯错!解析时:@angular/material-moment-adapter@12.1.4 npm 犯错!发现:@angular/material@12.0.6 npm ERR! node_modules/@angular/material@angular / material@”~ 12.0.4” 从根项目开始 ...
我们在Azure-Pipelines中使用npm ci进行清洁安装。
问题经常出在那个包裹上。Json和包锁。Json不再同步。
解决方案是执行npm install local并推送新的package-lock.json。
作为额外的提示,我们在管道中添加了一个新任务,以便在作业失败时获得额外的信息。
- task: Npm@1
displayName: npm install
inputs:
command: custom
customCommand: ci
customRegistry: useNpmrc
# ##vso[task.logissue type=error] writes the text to the summary page (error-log).
- bash: echo "##vso[task.logissue type=error] If 'npm install' fails with 'ERESOLVE could not resolve', 'package.json' and 'package-lock.json' (needed for 'npm ci') may be out of sync. Run 'npm install' locally and push the new package-lock.json."
condition: failed() # Only execute on fail
displayName: npm install failed hint
重置package-lock。Json一直都很适合我:
git checkout -- package-lock.json
细节: 在更新遗留项目的所有包时,我经常遇到这种情况——我强烈不建议使用npm审计fix或npm I——force。删除包锁。Json也并不总是适用于我。回滚到包的工作版本。Json +包锁。Json和添加包对我来说是最安全、最快的变体。
问题似乎是gf-kautomata-pipeline-ui使用的是Angular 9,而@angular/http需要Angular 7。(@angular/http已经弃用并最终被移除,它的所有功能都被移到了@angular/common中。)
见:https://www.npmjs.com/package/@angular http
如果你运行的是Angular 9,那么
从包中删除@angular/http。json(在Angular 9中你不需要它) 确保你的package.json中有@angular/common。 运行npm i。
如果你运行的是Angular 7,那么打开你的包。检查并确保你所有的Angular包都不高于^7.0.0。你可能还需要删除gf-kautomata-pipeline-ui,或者联系gf-kautomata-pipeline-ui的作者,看看这个库是否与Angular 7兼容。