chore: use cross-env for NODE_OPTIONS in npm scripts#2
Open
dejannenov wants to merge 1 commit intommgrillo:mainfrom
Open
chore: use cross-env for NODE_OPTIONS in npm scripts#2dejannenov wants to merge 1 commit intommgrillo:mainfrom
dejannenov wants to merge 1 commit intommgrillo:mainfrom
Conversation
The dev, dev:daemon, build, and start scripts previously prefixed NODE_OPTIONS using POSIX shell syntax (NODE_OPTIONS='...'). That syntax is not understood by Windows cmd.exe, which is the default shell npm uses to run scripts on Windows, so the scripts failed for Windows contributors regardless of which terminal launched them. Wrap the env var assignment with cross-env so the same script line works on Linux, macOS, and Windows (cmd, PowerShell, and Git Bash) without shell-specific syntax. Update CLAUDE.md accordingly. cross-env is added as a devDependency at ^10.1.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
dev,dev:daemon,build, andstartscripts previously setNODE_OPTIONSusing POSIX shell prefix syntax:That syntax is not understood by Windows
cmd.exe, which is the shell npm uses to run scripts on Windows by default (regardless of which terminal the user launchesnpm runfrom). The result is that contributors on Windows can't run the dev / build / start scripts at all without manually rewriting them.This PR wraps the env var assignment with
cross-envso the same script line works on Linux, macOS, and Windows (cmd, PowerShell, Git Bash) without shell-specific syntax.Changes
package.json: wrapNODE_OPTIONS=--require ./node-compat.cjsincross-env "..."for thedev,dev:daemon,build, andstartscripts.package.json/package-lock.json: addcross-env@^10.1.0as adevDependency.CLAUDE.md: update the "Dev server requires NODE_OPTIONS" note to reflect that the npm scripts now usecross-envso they work cross-platform without shell-specific syntax.Notes
cross-env@10.xrequires Node >= 20. The project already targets Next.js 15 (Node >= 18.18) and@types/node@^20, so this is consistent with the existing toolchain.cross-envsimply sets the env var and execs the next command, so the resultingnode/nextinvocation is identical.dev:daemonscript still uses bash backgrounding (> logs.txt 2>&1 &); that part is unchanged and remains bash-only as it was before.Test plan
npm installsucceeds and addscross-envtonode_modules.npm run devstarts the Next.js dev server on Linux / macOS.npm run devstarts the Next.js dev server on Windows (cmd.exe).npm run devstarts the Next.js dev server on Windows (Git Bash).npm run buildcompletes a production build on each platform.npm run startboots the built app on each platform.node-compat.cjsis still being preloaded (verify via any side effect it adds, orprocess.execArgv/NODE_OPTIONSlogging).🤖 Generated with Claude Code