在内部 Windows ADO 构建代理上更新 Node js

问题描述 投票:0回答:1

我正在尝试在需要 Node.js 版本 12> 的内部托管 Windows 代理上运行管道,但 UseNode@1 任务发现版本 10 已安装并跳过执行任何其他操作:

YAML 如下所示:

trigger:
- master

pool:
  name: Default

stages:
  - stage: GaugeStuff
    jobs:
    - job:
      steps:
      - task: UseNode@1
        inputs:
         versionSpec: 20.x
         checkLatest: true
      - powershell: |
          echo Installing Gauge
          npm install -g @getgauge/cli
        displayName: Install Gauge (npm)
      - powershell: |
          echo Installing Gauge
          npm install -g @taiko
        displayName: Install Taiko (npm)
      - powershell: |
          echo Starting Gauge Tests
          gauge run --tags "logon | stTests" specs

但是当运行时我得到这个:

##[节]开始:UseNode
2024-06-27T13:09:42.0664810Z 在缓存中找到工具:节点 10.24.1 x64
2024-06-27T13:09:42.0670955Z 在 PATH 环境变量前添加目录:E: gent_work_tool 颂歌.24.1\x64
2024-06-27T13:09:42.1189507Z ##[节]整理:UseNode

安装 Gauge 的下一步是:

安装
仪表
npm 警告 notsup [email protected] 不受支持的引擎:想要:{"node":">=12.0"}(当前:{"node":"10.24.1","npm":"6.14.12"} )
npm WARN notsup 与您的 Node/npm 版本不兼容:[电子邮件受保护]

如何强制代理更新到我想要的 Node js 版本,而不仅仅是使用缓存版本?

我假设 UseNode@1 会识别版本差异并更新。

azure-devops azure-pipelines azure-pipelines-yaml
1个回答
0
投票

versionSpec
参数在任务
UseNode@1
中无效。

指定节点版本,请使用

version

任务示例如下:

      - task: UseNode@1
        inputs:
          version: '12.x'           # specify the target version
          checkLatest: true
      - bash: node --version         # check the version

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.