Abhishek Konnur
Abhishek Konnur

Reputation: 531

Azure DevOps static web app automatically upgraded its node and npm versions

Recently while deploying a reactjs app as azure static web app, the automatic upgradation of node and npm caused error related to peer dependency.

Previous versions-

Using Node version:v14.19.1

Using Npm version:6.14.16

Current versions-

Using Node version:v16.18.0

Using Npm version:8.19.2

npm WARN ERESOLVE overriding peer dependency

npm WARN While resolving: @date-io/[email protected]

npm WARN Found: [email protected]

npm WARN node_modules/date-fns

npm WARN date-fns@"^2.29.3" from the root project

npm WARN 2 more (@mui/x-date-pickers, @date-io/date-fns)

npm WARN

npm WARN Could not resolve dependency:

npm WARN peer date-fns@"2.0.0-alpha.27" from @date-io/[email protected]

npm WARN node_modules/@date-io/date-fns

npm WARN @date-io/date-fns@"1.1.0" from [email protected]

npm WARN node_modules/material-table

What is the proper solution to resolve this issue, as I tried adding a task in yml file to upgrade node version, it did not work

Upvotes: 1

Views: 1020

Answers (2)

Reza Taba
Reza Taba

Reputation: 1904

You can basically add it as an environment:

- name: Build And Deploy
  id: builddeploy
  uses: Azure/static-web-apps-deploy@v1
  env:
    NODE_VERSION: 20.11.1
    NPM_CONFIG_LEGACY_PEER_DEPS: true # Also if --legacy-peer-deps needed.
  with:
    azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_OCEAN_0E8C92D0F }}

Upvotes: 0

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35119

The node.js is determined by project itself. It is not able to be set in YAML Pipeline via adding task.

Refer to this doc: Configure Azure Static Web Apps

You can add a file name: staticwebapp.config.json to your project and add the following code:

{
  "platform": {
    "apiRuntime": "node:14"
  }
}

For example:

enter image description here

Or you can define the Engines field in Package.json file.

For example:

{
 ...
  "engines": {
      "npm": "^6.14.17",
      "node": "^v14.20.1"
  },
....
}

Result:

enter image description here

Upvotes: 2

Related Questions