Skip to content

Commit 1c90fc8

Browse files
committed
🤖 fix: require Node.js v20+ for Storybook
The issue was that Node.js v18.19.1 had a conflict with esbuild-register when loading Vite code in Storybook's config. Specifically, esbuild-register was trying to declare 'const __dirname' but it was already declared in the environment, causing a SyntaxError. Node.js v20.19.4 resolves this issue. Changes: - Add Node.js version check to Makefile (requires v20+) - Apply version check to all Storybook-related targets - Add --no-open flag to storybook dev to prevent xdg-open errors on headless machines - Provide helpful error message with instructions to upgrade using 'n' _Generated with `cmux`_
1 parent 033eccc commit 1c90fc8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Makefile

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ include fmt.mk
4646
# Build tools
4747
TSGO := bun run node_modules/@typescript/native-preview/bin/tsgo.js
4848

49+
# Node.js version check
50+
REQUIRED_NODE_VERSION := 20
51+
NODE_VERSION := $(shell node --version | sed 's/v\([0-9]*\).*/\1/')
52+
53+
define check_node_version
54+
@if [ "$(NODE_VERSION)" -lt "$(REQUIRED_NODE_VERSION)" ]; then \
55+
echo "Error: Node.js v$(REQUIRED_NODE_VERSION) or higher is required"; \
56+
echo "Current version: v$(NODE_VERSION)"; \
57+
echo ""; \
58+
echo "To upgrade Node.js:"; \
59+
echo " 1. Install 'n' version manager: curl -L https://raw.githubusercontent.com/tj/n/master/bin/n | sudo bash -s -- lts"; \
60+
echo " 2. Or use 'n' if already installed: sudo n $(REQUIRED_NODE_VERSION)"; \
61+
echo ""; \
62+
exit 1; \
63+
fi
64+
endef
65+
4966
TS_SOURCES := $(shell find src -type f \( -name '*.ts' -o -name '*.tsx' \))
5067

5168
# Default target
@@ -244,15 +261,19 @@ docs-watch: ## Watch and rebuild documentation
244261

245262
## Storybook
246263
storybook: node_modules/.installed ## Start Storybook development server
247-
@bun x storybook dev -p 6006
264+
$(check_node_version)
265+
@bun x storybook dev -p 6006 --no-open
248266

249267
storybook-build: node_modules/.installed src/version.ts ## Build static Storybook
268+
$(check_node_version)
250269
@bun x storybook build
251270

252271
test-storybook: node_modules/.installed ## Run Storybook interaction tests (requires Storybook to be running or built)
272+
$(check_node_version)
253273
@bun x test-storybook
254274

255275
chromatic: node_modules/.installed ## Run Chromatic for visual regression testing
276+
$(check_node_version)
256277
@bun x chromatic --exit-zero-on-changes
257278

258279
## Benchmarks

0 commit comments

Comments
 (0)