gpt4 book ai didi

node.js - 执行 npm install 时出现 Azure DevOps CI 代理错误

转载 作者:行者123 更新时间:2023-12-03 06:56:52 25 4
gpt4 key购买 nike

我已经为 Angular 13 WEB APP 配置了 Azure DevOps CI 管道。 Node 版本是14.17NPM 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返回以下错误时

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: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e1019530d1b121b1d0a4c3e4f504a504f" rel="noreferrer noopener nofollow">[email protected]</a>
2022-07-05T08:50:59.0089028Z npm ERR! Found: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abd8cec7cec8df99eb9f859a859b86d9c8859b" rel="noreferrer noopener nofollow">[email protected]</a>
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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f6168227c6a636a6c7b3d4f3e213b213e" rel="noreferrer noopener nofollow">[email protected]</a>
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: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="344751585157400674001a041a0507" rel="noreferrer noopener nofollow">[email protected]</a>
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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d535a104e5851585e490f7d0c1309130c" rel="noreferrer noopener nofollow">[email protected]</a>
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

谁能帮我解决这个问题吗?

最佳答案

这与 Azure DevOps CI 管道本身无关。您对https://nodejs.org/en/blog/npm/peer-dependencies有疑问。总之,上游包依赖于托管应用程序在下游安装的支持包,并且版本可能受到很大限制。解决方法(根据错误消息)是使用 npm install --legacy-peer-deps https://docs.npmjs.com/cli/v7/using-npm/config#legacy-peer-deps 。您可以使用命令 npm info ng-select2 peerDependencies 找出包的对等依赖项。或特定版本npm info <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a5cbc288d6c0c9c0c6d197e5948b918b94" rel="noreferrer noopener nofollow">[email protected]</a> peerDependencies .

结果如下。请注意 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="68060f451b0d040d0b1c5a2859465c4659" rel="noreferrer noopener nofollow">[email protected]</a>依赖 select2@^4.0.x .

你安装了吗select2@^4.0.x

{
'@angular/common': '^13.0.0',
'@angular/core': '^13.0.0',
'@types/jquery': '3.5.x',
'@types/select2': '^4.0.x',
select2: '^4.0.x',
jquery: '3.5.x'
}

安装正确版本的 npm install select2@^4.0.0应该可以解决你的问题。

在您的 package.json 中:

"select2": "^4.0.0"

关于node.js - 执行 npm install 时出现 Azure DevOps CI 代理错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72867781/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com