Search code examples
azure-devopsazure-pipelinesazure-pipelines-yaml

Updating Node js on internal windows ADO build agent


I'm trying to run a pipeline on an internal hosted windows agent that needs version 12> of node.js but UseNode@1 task finds that version 10 is installed and skips doing anything else:

The YAML looks like this:

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

but when run I get this:

##[section]Starting: UseNode
2024-06-27T13:09:42.0664810Z Found tool in cache: node 10.24.1 x64
2024-06-27T13:09:42.0670955Z Prepending PATH environment variable with directory: E:\agent_work_tool\node\10.24.1\x64
2024-06-27T13:09:42.1189507Z ##[section]Finishing: UseNode

So next step of installing Gauge gets:

Installing
Gauge
npm WARN notsup Unsupported engine for [email protected]: wanted: {"node":">=12.0"} (current: {"node":"10.24.1","npm":"6.14.12"})
npm WARN notsup Not compatible with your version of node/npm: [email protected]

How can I force the agent to update to the version of Node js I want rather than just using the cached version?

I was assuming that UseNode@1 would recognise the version difference and update.


Solution

  • The versionSpec parameter is invalid in task UseNode@1.

    The specify the node version, please use version.

    Task sample as below:

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

    enter image description here