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.
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:
And have the version of Node.js you require installed by Oryx.