angularazureazure-static-web-app

Build and Deploy Job failing due to invaid Node version on Azure


I have an Angular App which is building fine on my local with Latest Angular and Node versions.. However, when i deploy it to Azure Static Web app, the build is failing and giving the below error.

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

I have included the engine tag in package.json as below.. but its not helping.. Can someone please help here

"engines": {
    "node": ">=18.0.0"
  },

Solution

  • I created a sample angular application and have successfully deployed the app to Azure static web app via GitHub actions.

    I got the same error while deploying the app to Azure Static Web App.

    enter image description here

    Complete yaml file:

    name: Azure Static Web Apps CI/CD
    on:
      push:
        branches:
          - main
      pull_request:
        types: [opened, synchronize, reopened, closed]
        branches:
          - main
    jobs:
      build_and_deploy_job:
        if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
        runs-on: ubuntu-latest
        name: Build and Deploy Job
        steps:
          - uses: actions/checkout@v3
            with:
              submodules: true
              lfs: false
          - name: Set up Node.js
            uses: actions/setup-node@v2
            with:
              node-version: '20.x' 
          - name: Install dependencies
            run: npm install
          - name: Build Angular app
            run: npm run build -- --configuration=production
          - name: Build And Deploy
            id: builddeploy
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_STONE_0BC3E2B0F }}
              repo_token: ${{ secrets.GITHUB_TOKEN }}
              action: "upload"
              app_location: "/" 
              output_location: "dist/angulartest18/browser" 
              
      close_pull_request_job:
        if: github.event_name == 'pull_request' && github.event.action == 'closed'
        runs-on: ubuntu-latest
        name: Close Pull Request Job
        steps:
          - name: Close Pull Request
            id: closepullrequest
            uses: Azure/static-web-apps-deploy@v1
            with:
              azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_STONE_0BC3E2B0F }}
              action: "close"
    

    Successfully deployed the app to Azure Static Web App via GitHub actions.

    enter image description here

    enter image description here