Problem setting node version of linux web application from Azure Pipeline

Anon-7230 20 Reputation points
2024-06-04T13:07:01.88+00:00

I'm setting up a CICD pipeline with Azure Pipelines from Azure DevOps for a node application but it is failing to start as the default node version being used is node 16 when it requires node 18. I have tried to update the version through my pipeline but it seems to have no effect.

# Above this is variable configuration
pool:
  vmImage: ubuntu-latest

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: NodeTool@0
      inputs:
        versionSource: 'spec'
        versionSpec: '>=18.x'

    - script: |
        npm cache clean --force
        npm install
        npm run build
      displayName: 'npm install and build'

    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:
          - task: NodeTool@0
            inputs:
              versionSource: 'spec'
              versionSpec: '>=18.x'
          - task: AzureWebApp@1
            displayName: 'Azure Web App Deploy: $(webAppName)'
            inputs:
              azureSubscription: '$(subscription-id)'
              appType: webAppLinux
              appName: $(webAppName)
              runtimeStack: 'NODE|18LTS'
              package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
              startUpCommand: npm run startAzure


I have also tried to set the node version in the application settings with WEBSITE_NODE_DEFAULT_VERSION set with 18.x or a more specific version and it is still starting with v16.

User's image I've also tried the task UseNode@1 task but the same node version being used is 16.

User's image

The version is not updating in stack setting:

User's image

When I looked online it was suggested to add the node version to the package.json file which i've also done like the below.

  "engines": {
    "node": "18.19.1"
  }


But i'm still seeing version 16 in the logs on application startup

NodeJS Version : v16.14.2

When I check the node version it says v20.13.1 so i'm not sure why the node version is not updating when the app is starting.

User's image

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,913 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
968 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anon-7230 20 Reputation points
    2024-06-04T15:12:02.8733333+00:00

    Sorted the problem out by changing runtimeStack: 'NODE|18 LTS' to runtimeStack: 'NODE|18-lts', for some reason the former was the default in the pipeline editor and it wasn't until I kept looking around for answers and also used the Tasks builder as shown below to see the correct syntax for the AzureWebApp@1 task

    User's image

    User's image

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.