Skip to content

chore: use cross-env for NODE_OPTIONS in npm scripts#2

Open
dejannenov wants to merge 1 commit intommgrillo:mainfrom
dejannenov:chore/cross-env-npm-scripts
Open

chore: use cross-env for NODE_OPTIONS in npm scripts#2
dejannenov wants to merge 1 commit intommgrillo:mainfrom
dejannenov:chore/cross-env-npm-scripts

Conversation

@dejannenov
Copy link
Copy Markdown

Summary

The dev, dev:daemon, build, and start scripts previously set NODE_OPTIONS using POSIX shell prefix syntax:

"dev": "NODE_OPTIONS='--require ./node-compat.cjs' next dev --turbopack"

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 launches npm run from). 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-env so the same script line works on Linux, macOS, and Windows (cmd, PowerShell, Git Bash) without shell-specific syntax.

Changes

  • package.json: wrap NODE_OPTIONS=--require ./node-compat.cjs in cross-env "..." for the dev, dev:daemon, build, and start scripts.
  • package.json / package-lock.json: add cross-env@^10.1.0 as a devDependency.
  • CLAUDE.md: update the "Dev server requires NODE_OPTIONS" note to reflect that the npm scripts now use cross-env so they work cross-platform without shell-specific syntax.

Notes

  • cross-env@10.x requires Node >= 20. The project already targets Next.js 15 (Node >= 18.18) and @types/node@^20, so this is consistent with the existing toolchain.
  • Behavior on Linux / macOS is unchanged — cross-env simply sets the env var and execs the next command, so the resulting node/next invocation is identical.
  • The dev:daemon script still uses bash backgrounding (> logs.txt 2>&1 &); that part is unchanged and remains bash-only as it was before.

Test plan

  • npm install succeeds and adds cross-env to node_modules.
  • npm run dev starts the Next.js dev server on Linux / macOS.
  • npm run dev starts the Next.js dev server on Windows (cmd.exe).
  • npm run dev starts the Next.js dev server on Windows (Git Bash).
  • npm run build completes a production build on each platform.
  • npm run start boots the built app on each platform.
  • node-compat.cjs is still being preloaded (verify via any side effect it adds, or process.execArgv / NODE_OPTIONS logging).

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant