24

Azure Static Web Apps: Node.js 16 and Oryx

 1 year ago
source link: https://blog.johnnyreilly.com/2022/05/28/azure-static-web-apps-node-16-oryx
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Azure Static Web Apps: Node.js 16 and Oryx

May 28, 2022 · 2 min read

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.

title image reading "Azure Static Web Apps: Node.js 16 and Oryx" with Azure and Node.js logos

The engine "node" is incompatible

As I was upgrading this blog to Docusaurus v2.0.0-beta.21 I noticed this error in my build:

error @docusaurus/[email protected]: The engine "node" is incompatible with this module. Expected version ">=16.14". Got "14.19.1"
error Found incompatible module.


---End of Oryx build logs---
Oryx has failed to build the solution.

Oryx, which performs the build for Static Web Apps, is fixed to Node 14 it seems. Or it may actually be that the GitHub Action is fixed to use Node.js 14 - I'm not completely sure. Either way, Docusaurus now requires Node 16. Frustratingly, the GitHub Action does not allow explicit configuration of the Node version. Happily, there is a way to resolve this - and it's pretty simple.

engines to the rescue!

You can specify the node version you require in your package.json with the engines property. This means you can do something like this:

  "engines": {
"node": ">=16"
}

And have the version of Node.js you require installed by Oryx.

Thanks to Cormac McCarthy for his comment which lead me to try this approach out.

You can see the PR where I made this change for my blog here.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK