Azure Static Web Apps build and deploy Action Azure/static-web-apps-deploy@v1
appers to be fixed to Node.js 14.x
, which throws errors when build against the latest version of Docusaurus (v2.0.1)
which requires >=16.14
.
> docusaurus build
[ERROR] Minimum Node.js version not met :(
[INFO] You are using Node.js v14.19.1, Requirement: Node.js >=16.14.
...
---End of Oryx build logs---
Oryx has failed to build the solution.
GitHub Action YAML
I have the following job in my CI/CD pipeline, using the Azure/static-web-apps-deploy@v1
action:
jobs:
build_and_deploy_job:
if: github.event_name == 'push'
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
...
Error Logs
Without digging into documentation, we can inspect the error message in the GitHub Action log and find some helpful information:
> docusaurus build
[ERROR] Minimum Node.js version not met :(
[INFO] You are using Node.js v14.19.1, Requirement: Node.js >=16.14.
...
---End of Oryx build logs---
Oryx has failed to build the solution.
It appears the action Azure/static-web-apps-deploy@v1
is uing Oryx to build the project.
Oryx, engines
and package.json
From the Oryx GitHub ReadMe
:
Oryx is a build system which automatically compiles source code repos into runnable artifacts. It is used to build web apps for Azure App Service and other platforms.
After searching the repo documentation and issues, I came across the following comment:
Oryx just released an update to our CLI that now supports detecting the
engines
field in a user'spackage.json
file, and more specifically, parsing a version spec that's provided for thenpm
property within this field.
Sounds simple enough. So I update my package.json:
{
"name": "suttco",
...
"engines": {
"node": ">=16"
}
}
And just like that, my build and deploy succeeds!
Conclusion
Despite the action Azure/static-web-apps-deploy@v1
being fixed to a specific version of Node.js
, the developers have surfaced a simple approach to explicitly specifying a particular version of Node.js
and NPM
using existing package.json
properties.
You can read more about engines in the NPM CLI docs.
The GitHub issue also linked to a similiar blog post by John Reilly, so go check that out.