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

node --run does not honor script-shell configuration of .npmrc #56456

Closed
michkot opened this issue Jan 3, 2025 · 2 comments
Closed

node --run does not honor script-shell configuration of .npmrc #56456

michkot opened this issue Jan 3, 2025 · 2 comments

Comments

@michkot
Copy link

michkot commented Jan 3, 2025

Version

22

Platform

Windows

Subsystem

No response

What steps will reproduce the bug?

This is related to recently added feature #52190

1

Define package with package.json script that is executable in POSIX shell, but it is not executable/portable on cmd.exe.

2

Set script-shell configuration option in .npmrc in your package folder to "bash" (or "sh") to allow cross-platform execution of the script (Scripts will be cross platform as long as the target Windows machine has essential UNIX tools support, e.g. WSL or MSYS/Cygiwn installed).

2

Add a script with the following code or similar: NODE_OPTIONS='--max-old-space-size=8192' ./node_modules/jest/bin/jest

4

Run the script using "npm run", "pnpm run" on Windows system with "bash" available. Will work ok.

Run the script using "node --run". Script will fail with 'NODE_OPTIONS' is not recognized as an internal or external command, operable program or batch file.

How often does it reproduce? Is there a required condition?

N/A

What is the expected behavior? Why is that the expected behavior?

Node --run should work consistently with npm run, pnpm run, etc., in regards to which shell is used to run scripts.

What do you see instead?

See above - Scripts are always executed in default system shell, disregarding .npmrc script-shell option.

Additional information

No response

@nodejs nodejs deleted a comment Jan 3, 2025
@nodejs nodejs deleted a comment Jan 3, 2025
@anonrig
Copy link
Member

anonrig commented Jan 4, 2025

Node --run is not a replacement of npm or yarn and does not follow npm specific settings. This is intended.

@anonrig anonrig closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
@michkot
Copy link
Author

michkot commented Jan 6, 2025

@anonrig I was sort of expecting that answer - let me then just say (as a feedback to a feature being "in adoption") the way this was added, I am afraid node --run is IMO a mistake and will lead increase the existing huge headache of (non-)portability of npm scripts (that we struggle with in devops quite frequently). Thanks for reviewing this promptly tho!

Picking up some previous feedback I can confirm:
#46534 (comment) <- noting that package managers actually do much more when running tasks

#46534 (comment) <- " if this is something that Deno already does, that’s a clear enough signal that Node could do it too", yes, but Deno uses cross-platform shell (similar to yarn and pnpm opt-in feature), not "default system shell" to execute scripts, which makes it much more usable.

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

No branches or pull requests

3 participants
@anonrig @michkot and others