错误 Angular CLI 要求 Azure Pipelines 中的 Node.js 版本最低为 v18.13

mic*_*cer 2 azure node.js azure-devops angular-cli angular

我的 Azure 管道开始失败。我的错误如下:

Node.js version v16.20.2 detected.
The Angular CLI requires a minimum Node.js version of v18.13.

Run Code Online (Sandbox Code Playgroud)

我没有改变任何东西。这是我的管道的一部分:

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'

- script: |
    sudo npm install -g @angular/cli
    npm install
    ng build -c=release --output-path=web/wwwroot
  displayName: 'npm install and build'
Run Code Online (Sandbox Code Playgroud)

两周前该脚本有效。

我的问题是,如何在Azure管道中修复它?我正在使用 Microsoft 托管代理

Kev*_*SFT 7

我可以使用相同的 YAML 管道重现相同的问题。

在此输入图像描述

问题的原因是命令:npm install -g @angular/cli默认会下载最新的 Angular cli 包。

最新的 Angular CLI 版本 17.0.0 请求节点版本 18.13。

要解决此问题,可以降级 Azure Pipeline 中的 Angular CLI 版本。

例如:npm install -g @angular/cli@16.2.10

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'

- script: |
    npm install -g @angular/cli@16.2.10
    npm install
    ng build --prod
  displayName: 'npm install and build'
Run Code Online (Sandbox Code Playgroud)