Skip to content

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

@michkot

Description

@michkot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions