Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade #228

Merged
merged 9 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@ jobs:
azure_static_web_apps_api_token: ${{ steps.static_web_app_apikey.outputs.APIKEY }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: '/blog-website' # App source code path
api_location: '' # Api source code path - optional
output_location: 'build' # Built app content directory - optional
###### End of Repository/Build Configurations ######

# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
api_location: '' # Api source code path - optional

- name: Static Web App - get preview URL
id: static_web_app_preview_url
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: 'Azure Static Web Apps: Node.js 16 and Oryx'
authors: johnnyreilly
tags: [Azure Static Web Apps, GitHub Actions, Docusaurus, Node.js, Oryx]
hide_table_of_contents: false
---

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](title-image.png)

## The engine "node" is incompatible

As I was upgrading this blog to [Docusaurus v2.0.0-beta.21](https://github.com/facebook/docusaurus/releases/tag/v2.0.0-beta.21) I noticed this error in my build:

```shell
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](https://github.com/microsoft/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`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#engines) property. This means you can do something like this:

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

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

Thanks to [Cormac McCarthy](https://github.com/cormacpayne) for his [comment](https://github.com/Azure/static-web-apps/issues/694#issuecomment-1137492562) which lead me to try this approach out.

[You can see the PR where I made this change for my blog here.](https://github.com/johnnyreilly/blog.johnnyreilly.com/pull/228)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions blog-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-beta.20",
"@docusaurus/plugin-client-redirects": "^2.0.0-beta.20",
"@docusaurus/plugin-ideal-image": "^2.0.0-beta.20",
"@docusaurus/plugin-pwa": "^2.0.0-beta.20",
"@docusaurus/preset-classic": "^2.0.0-beta.20",
"@docusaurus/core": "^2.0.0-beta.21",
"@docusaurus/plugin-client-redirects": "^2.0.0-beta.21",
"@docusaurus/plugin-ideal-image": "^2.0.0-beta.21",
"@docusaurus/plugin-pwa": "^2.0.0-beta.21",
"@docusaurus/preset-classic": "^2.0.0-beta.21",
"@mdx-js/react": "^1.6.21",
"@svgr/webpack": "^6.1.1",
"clsx": "^1.1.1",
Expand All @@ -31,7 +31,7 @@
"webpack-font-preload-plugin": "^1.5.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.0.0-beta.20",
"@docusaurus/module-type-aliases": "^2.0.0-beta.21",
"@tsconfig/docusaurus": "^1.0.5",
"typescript": "^4.6.3"
},
Expand All @@ -46,5 +46,9 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"engines": {
"node": ">=16",
"yarn": "^1.22.10"
}
}
Loading