Skip to content

Commit 606495c

Browse files
authored
Better specify expected Node.js version and update to v20.19.2 (#399)
The container image was pinned to Node.js 20.18.1, see `Dockerfile`: ``` docker FROM node:20.18.1-bullseye-slim AS base ``` But attempting to use 20.18.1 to build Storybook, you encounter an error: ``` { column: 35, file: '/home/doshitan/projects/platform-test-nextjs/app/.storybook/main.mjs', length: 11, line: 29, lineText: ' nextConfigPath: path.resolve(import.meta.dirname, "../next.config.js"),', namespace: '', suggestion: '' } "import.meta" is not available with the "cjs" output format and will be empty SB_CORE-SERVER_0007 (MainFileEvaluationError): Storybook couldn't evaluate your .storybook/main.mjs file. ``` This is due to a recent change[1] that switched to using `import.meta.dirname`, a feature of Node.js ESM loading, instead of the legacy `__dirname`. But automatic detection and loading a file as ESM is behind a feature flag until Node.js v20.19.0[2]. Thus breaking the Storybook build for the project's "official" Node 20.18.1 version and container workflow. So: - Update Node.js version to 20.19.2 - Add specific version requirement to `package.json`, which at least will display a warning to folks installing packages outside the container environment. - Use `package.json` specification to load the correct Node.js version in CI Which should help keep all the different environments in sync. And the new Node.js module behavior is the default in later versions as well, so might as well lean into it. [1] #392 [2] https://nodejs.org/en/blog/release/v20.19.0/#requireesm-is-now-enabled-by-default
1 parent c7ec42d commit 606495c

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

template/.github/workflows/cd-{{app_name}}-storybook.yml.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: Setup Node
4343
uses: actions/setup-node@v4
4444
with:
45-
node-version: 20
45+
node-version-file: ./{{ app_name }}/package.json
4646
cache-dependency-path: ./{{ app_name }}/package-lock.json # or yarn.lock
4747
cache: npm # or yarn
4848
- name: Setup Pages

template/.github/workflows/ci-{{app_name}}.yml.jinja

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ defaults:
1414
working-directory: ./{{ app_name }}
1515

1616
env:
17-
NODE_VERSION: 20
17+
NODE_VERSION_FILE: ./{{ app_name }}/package.json
1818
LOCKFILE_PATH: ./{{ app_name }}/package-lock.json # or yarn.lock
1919
PACKAGE_MANAGER: npm # or yarn
2020

@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
- uses: actions/setup-node@v4
3333
with:
34-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
34+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
3535
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
3636
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
3737
- run: npm ci
@@ -52,7 +52,7 @@ jobs:
5252
- uses: actions/checkout@v4
5353
- uses: actions/setup-node@v4
5454
with:
55-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
55+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
5656
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
5757
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
5858
- run: npm ci
@@ -66,7 +66,7 @@ jobs:
6666
- uses: actions/checkout@v4
6767
- uses: actions/setup-node@v4
6868
with:
69-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
69+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
7070
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
7171
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
7272
- run: npm ci
@@ -80,7 +80,7 @@ jobs:
8080
- uses: actions/checkout@v4
8181
- uses: actions/setup-node@v4
8282
with:
83-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
83+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
8484
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
8585
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
8686
- run: npm ci
@@ -95,7 +95,7 @@ jobs:
9595
- uses: actions/checkout@v4
9696
- uses: actions/setup-node@v4
9797
with:
98-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
98+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
9999
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
100100
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
101101

@@ -123,7 +123,7 @@ jobs:
123123
- uses: actions/checkout@v4
124124
- uses: actions/setup-node@v4
125125
with:
126-
node-version: ${{'{{'}} env.NODE_VERSION {{'}}'}}
126+
node-version-file: ${{'{{'}} env.NODE_VERSION_FILE {{'}}'}}
127127
cache-dependency-path: ${{'{{'}} env.LOCKFILE_PATH {{'}}'}}
128128
cache: ${{'{{'}} env.PACKAGE_MANAGER {{'}}'}}
129129
- run: npm ci

template/{{app_name}}/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is largely based on the template-application-flask Dockerfile and
22
# Next.js Docker example: https://github.com/vercel/next.js/blob/canary/examples/with-docker-compose
33
# =============================================================================
4-
FROM node:20.18.1-bullseye-slim AS base
4+
FROM node:20.19.2-bullseye-slim AS base
55
WORKDIR /app
66

77
# Install dependencies

template/{{app_name}}/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

template/{{app_name}}/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"engines": {
6-
"node": ">=20.0.0",
6+
"node": "20.19.2",
77
"npm": ">=10.0.0"
88
},
99
"scripts": {

0 commit comments

Comments
 (0)