Search code examples
node.jsangularazureazure-devopsangular-cli

Error The Angular CLI requires a minimum Node.js version of v18.13 in Azure Pipelines


My Azure pipeline started to fail. My error is at follows:

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

I didnt change anything. This is part of my pipeline:

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'

Two weeks ago that script works.

My question is, how to fix it in Azure pipelines? I am using Microsoft hosted agents


Solution

  • I can reproduce the same issue with the same YAML Pipeline.

    enter image description here

    The cause of the issue is that the command: npm install -g @angular/cli will download the latest angular cli package by default.

    The latest Angular CLI version 17.0.0 requests the node version 18.13.

    To solve this issue, you can downgrade the angular CLI version in Azure Pipeline.

    For example: npm install -g @angular/[email protected]

    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '16.x'
      displayName: 'Install Node.js'
    
    - script: |
        npm install -g @angular/[email protected]
        npm install
        ng build --prod
      displayName: 'npm install and build'