Azure DevOps CI代理商错误时,请安装NPM
我为Angular 13 Web应用程序配置了Azure Devops CI管道。节点版本为14.17 NPM 6.14.13使用了Azure代理Ubuntu 20.04 LTS。在下面,您可以看到我构建的
resources:
repositories:
- repository: self
type: git
ref: refs/heads/development
jobs:
- job: Job_1
displayName: Agent job 1
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
- task: NodeTool@0
displayName: Use Node 14.17.x
inputs:
versionSpec: 14.17.x
- task: CmdLine@2
displayName: Install Anguler
inputs:
script: npm install -g @angular/cli
- task: Npm@1
displayName: npm install
inputs:
verbose: false
- task: CmdLine@1
displayName: Run ng
inputs:
filename: ng
arguments: build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: dist
ArtifactName: dist
问题是 npm install 在Errror之后返回时,
2022-07-05T08:50:59.0085431Z npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
2022-07-05T08:50:59.0086707Z npm ERR! code ERESOLVE
2022-07-05T08:50:59.0087276Z npm ERR! ERESOLVE could not resolve
2022-07-05T08:50:59.0087839Z npm ERR!
2022-07-05T08:50:59.0088385Z npm ERR! While resolving: [email protected]
2022-07-05T08:50:59.0089028Z npm ERR! Found: [email protected]
2022-07-05T08:50:59.0089656Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0090324Z npm ERR! select2@"^4.1.0-rc.0" from the root project
2022-07-05T08:50:59.0091059Z npm ERR!
2022-07-05T08:50:59.0091557Z npm ERR! Could not resolve dependency:
2022-07-05T08:50:59.0092182Z npm ERR! peer select2@"^4.0.x" from [email protected]
2022-07-05T08:50:59.0092812Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0093479Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0094043Z npm ERR!
2022-07-05T08:50:59.0094606Z npm ERR! Conflicting peer dependency: [email protected]
2022-07-05T08:50:59.0095230Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0095824Z npm ERR! peer select2@"^4.0.x" from [email protected]
2022-07-05T08:50:59.0096597Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0097203Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0097691Z npm ERR!
2022-07-05T08:50:59.0098212Z npm ERR! Fix the upstream dependency conflict, or retry
2022-07-05T08:50:59.0098870Z npm ERR! this command with --force, or --legacy-peer-deps
2022-07-05T08:50:59.0099604Z npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
2022-07-05T08:50:59.0102846Z npm ERR!
2022-07-05T08:50:59.0103438Z npm ERR! See C:\npm\cache\eresolve-report.txt for a full report.
2022-07-05T08:50:59.0103769Z
2022-07-05T08:50:59.0104331Z npm ERR! A complete log of this run can be found in:
2022-07-05T08:50:59.0105127Z npm ERR! C:\npm\cache\_logs\2022-07-05T08_50_56_733Z-debug-0.log
2022-07-05T08:50:59.1265632Z ##[warning]Couldn't find a debug log in the cache or working directory
2022-07-05T08:50:59.1289161Z ##[error]Error: Npm failed with return code: 1
2022-07-05T08:50:59.1322525Z ##[section]Finishing: npm install
有人可以帮助我吗?
I have configured Azure DevOps CI pipe for Angular 13 WEB APP. The Node version is 14.17
and NPM 6.14.13 used azure agent Ubuntu 20.04 LTS. Below you can see what I included to my build
resources:
repositories:
- repository: self
type: git
ref: refs/heads/development
jobs:
- job: Job_1
displayName: Agent job 1
pool:
vmImage: ubuntu-20.04
steps:
- checkout: self
- task: NodeTool@0
displayName: Use Node 14.17.x
inputs:
versionSpec: 14.17.x
- task: CmdLine@2
displayName: Install Anguler
inputs:
script: npm install -g @angular/cli
- task: Npm@1
displayName: npm install
inputs:
verbose: false
- task: CmdLine@1
displayName: Run ng
inputs:
filename: ng
arguments: build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: dist'
inputs:
PathtoPublish: dist
ArtifactName: dist
The problem is when it comes to npm install returning following errror
2022-07-05T08:50:59.0085431Z npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
2022-07-05T08:50:59.0086707Z npm ERR! code ERESOLVE
2022-07-05T08:50:59.0087276Z npm ERR! ERESOLVE could not resolve
2022-07-05T08:50:59.0087839Z npm ERR!
2022-07-05T08:50:59.0088385Z npm ERR! While resolving: [email protected]
2022-07-05T08:50:59.0089028Z npm ERR! Found: [email protected]
2022-07-05T08:50:59.0089656Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0090324Z npm ERR! select2@"^4.1.0-rc.0" from the root project
2022-07-05T08:50:59.0091059Z npm ERR!
2022-07-05T08:50:59.0091557Z npm ERR! Could not resolve dependency:
2022-07-05T08:50:59.0092182Z npm ERR! peer select2@"^4.0.x" from [email protected]
2022-07-05T08:50:59.0092812Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0093479Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0094043Z npm ERR!
2022-07-05T08:50:59.0094606Z npm ERR! Conflicting peer dependency: [email protected]
2022-07-05T08:50:59.0095230Z npm ERR! node_modules/select2
2022-07-05T08:50:59.0095824Z npm ERR! peer select2@"^4.0.x" from [email protected]
2022-07-05T08:50:59.0096597Z npm ERR! node_modules/ng-select2
2022-07-05T08:50:59.0097203Z npm ERR! ng-select2@"^1.4.1" from the root project
2022-07-05T08:50:59.0097691Z npm ERR!
2022-07-05T08:50:59.0098212Z npm ERR! Fix the upstream dependency conflict, or retry
2022-07-05T08:50:59.0098870Z npm ERR! this command with --force, or --legacy-peer-deps
2022-07-05T08:50:59.0099604Z npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
2022-07-05T08:50:59.0102846Z npm ERR!
2022-07-05T08:50:59.0103438Z npm ERR! See C:\npm\cache\eresolve-report.txt for a full report.
2022-07-05T08:50:59.0103769Z
2022-07-05T08:50:59.0104331Z npm ERR! A complete log of this run can be found in:
2022-07-05T08:50:59.0105127Z npm ERR! C:\npm\cache\_logs\2022-07-05T08_50_56_733Z-debug-0.log
2022-07-05T08:50:59.1265632Z ##[warning]Couldn't find a debug log in the cache or working directory
2022-07-05T08:50:59.1289161Z ##[error]Error: Npm failed with return code: 1
2022-07-05T08:50:59.1322525Z ##[section]Finishing: npm install
Can anyone help me on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这与Azure Devops CI管道本身无关。您遇到 https://nodejs.org/en/blog/blog/npm/peer - 依赖性。总而言之,上游软件包依赖于托管应用程序下游安装的支持软件包,并且版本可以非常限制。解决方法(根据错误消息)是使用
npm install -legacy-peer-deps
https://docs.npmjs.com/cli/v7/usise-npm/config#legacy-peer-deps 。您可以通过使用命令npm info ng-select2 peerDepentencies
或特定版本npm info [email  prectioned] peerDependendencencies
。下面的结果。请注意,
代码> select2@^4.0.x
。您是否已安装
select2@^4.0.x
?安装
npm的正确版本安装select2@^4.0.0
应该解决您的问题。在您的
package.json
中:This has nothing to do with the Azure DevOps CI pipeline per se. You have a problem with https://nodejs.org/en/blog/npm/peer-dependencies. In summary, an upstream package relies on a supporting package being installed downstream by the hosting application and versions can be quite restricted. The workaround (as per the error message) is to use
npm install --legacy-peer-deps
https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps . You can find out what the peer dependencies for a package are by using the commandnpm info ng-select2 peerDependencies
or specific versionnpm info [email protected] peerDependencies
.Result below. Notice that
[email protected]
relies onselect2@^4.0.x
.Have you installed
select2@^4.0.x
?Installing the correct version of
npm install select2@^4.0.0
should solve your problem.In your
package.json
: