Specify your Node.js version for the Azure Static Web App GitHub Action

profile
Tim Deschryver
timdeschryver.dev

While migrating my blog to an Azure Static Web App, I encountered a minor issue that occured during the build process within the GitHub workflow.

I created the Azure Static Web App via the Azure Portal (you can also use the VSCode Extension, or the Azure CLI), which automatically created a GitHub workflow (azure-static-web-apps-salmon-rock-0fb035b03.yml) on my GitHub repository.

The worflow uses the Azure/static-web-apps-deploy GitHub action to build and deploy the application, and was already pre-configured.

The problem I encountered was that my blog required a different Node.js version than the one that was used by the action. The action was using the default Node.js version (14.x), while my blog required version 16.x.

The GitHub Action uses Node.js v14.x by default

Because the GitHub action doesn't support specifying a Node.js version, the solution is to specify the Node.js version within the package.json file. To do this, use the engines field.

The GitHub Action uses Node.js v16.x after we specified the node version in the package.json

Feel free to update this blog post on GitHub, thanks in advance!

Join My Newsletter (WIP)

Join my weekly newsletter to receive my latest blog posts and bits, directly in your inbox.

Support me

I appreciate it if you would support me if have you enjoyed this post and found it useful, thank you in advance.

Buy Me a Coffee at ko-fi.com PayPal logo

Share this post