You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps Pipeline部署报错:Node.js版本不符合Angular CLI要求

问题:Azure DevOps Pipeline因Node.js版本不兼容导致npm install/build失败

我是Azure新手,尝试从GitHub仓库部署Azure DevOps Pipeline,但在npm install和build阶段任务失败。报错显示检测到Node.js版本v10.24.1,而Angular CLI要求最低Node.js版本为v14.20、v16.13或v18.10。本地Node.js版本为v18,但Azure的Node.js工具安装任务自动下载并使用了v10.24.1,不清楚如何修改该版本。

安装日志:

Starting: Install Node.js
Task : Node.js tool installer

Description : Finds or downloads and caches the specified version spec of Node.js and adds it to the PATH
Version : 0.218.0
Author : Microsoft Corporation

Downloading: node-v10.24.1-linux-x64.tar.gz
Extracting archive
/usr/bin/tar xC /home/vsts/work/_temp/03b1dcb9-eb8c-4670-a1e8-005b1a301667 -f /home/vsts/work/_temp/f4579837-7ffe-4b90-885d-a007e659aa26
Caching tool: node 10.24.1 x64
Prepending PATH environment variable with directory: /opt/hostedtoolcache/node/10.24.1/x64/bin
Finishing: Install Node.js

相关截图:

install node.js - azure pipeline
Npm install and build error


解决方案

可视化编辑器修改步骤

  1. 打开Azure DevOps Pipeline的编辑页面
  2. 找到Node.js tool installer任务
  3. 在任务的Version spec字段中,输入符合Angular要求的版本,比如18.x(与本地版本一致),或者16.13.x/14.20.x这类最低兼容版本
  4. 保存Pipeline并重新运行

YAML配置直接修改

如果你的Pipeline采用YAML定义,找到NodeTool任务块,修改versionSpec参数:

- task: NodeTool@0
  inputs:
    versionSpec: '18.x' # 可替换为16.13.x、14.20.x等兼容版本
  displayName: 'Install Node.js'

修改完成后重新触发Pipeline,Node.js工具安装任务将下载并使用指定的兼容版本,满足Angular CLI的版本要求,解决构建失败问题。

内容的提问来源于stack exchange,提问作者Beth McCoy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 23:32:49