{
  "$type": "site.standard.document",
  "canonicalUrl": "https://johnnyreilly.com/posts/azure-static-web-apps-node-16-oryx",
  "description": "Azure Static Web Apps presently fixes to Node.js 14 when building. If you require a different version of Node to build, here is how.",
  "path": "/posts/azure-static-web-apps-node-16-oryx",
  "publishedAt": "2022-05-28T00:00:00.000Z",
  "site": "at://did:plc:yy3apqjlms24kso7ahn7lbmb/site.standard.publication/3mova7c4nho2b",
  "tags": [
    "azure static web apps",
    "github actions",
    "docusaurus",
    "node.js",
    "azure"
  ],
  "textContent": "Azure Static Web Apps presently fixes to Node.js 14 when building. If you require a different version of Node to build, this can be a problem. This post outlines a workaround.\n\n\n\nThe engine \"node\" is incompatible\n\nAs I was upgrading this blog to Docusaurus v2.0.0-beta.21 I noticed this error in my build:\n\nOryx, which performs the build for Static Web Apps, is fixed to Node 14 for the default LTS version (for now, this will definitely change sometime in 2023). You can check for the constant NodeLtsVersion here to check which version of Node Oryx is using as the DEFAULT_NODE_VERSION. To override this default, can either use an engines setting in package.json, or use an environment setting in the The GitHub Action.\n\nSolution 1: engines to the rescue!\n\nYou can specify the node version you require in your package.json with the engines property. This means you can do something like this:\n\nAnd have the version of Node.js you require installed by Oryx.\n\nThanks to Cormac McCarthy for his comment which lead me to try this approach out.\n\nYou can see the PR where I made this change for my blog here.\n\nSolution 2: Environment variables for the win!\n\nYou can change the version for the build step using an environnment variable. This is documented in the Microsoft Docs\n\nModify the workflow file, from the ./github/workflows directory. Just add these last two lines:\n\nYou can use a specific node version (18.12.0 or 16.18.0) or a major node version (18 or 16). The latter approach installs the latest minor version.\n\nNote: The Oryx image is updated quarterly. You can get a list of the supported node versions here.\n\nThanks to Eric Côté from React Academy for the information.",
  "title": "Azure Static Web Apps: Node.js 16 / 18 and Oryx"
}