Open
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
Using the following script:
#!/usr/bin/env node
console.log(process.argv[process.argv.length - 1]);
and package.json
with "bin": "./index.js",
.
When I run the script with multiline arguments in node
and npx
, I get the different results on Powershell:
PowerShell 7.4.5/Windows 11
Note there is a missing second line on the npx
output
PS > node .\index.js "a`nb"
a
b
PS > npx . "a`nb"
a
bash/linux
root@host:/app# node index.js $'a\nb'
a
b
root@host:/app# npx . $'a\nb'
a
b
Expected Behavior
Since I'm writing a CLI tool that relies heavily on multiline arguments, I expected the same behaviour between shells:
PowerShell 7.4.5/Windows 11
PS > node .\index.js "a`nb"
a
b
PS > npx . "a`nb"
a
b
bash
root@host:/app# node index.js $'a\nb'
a
b
root@host:/app# npx . $'a\nb'
a
b
A similar bug was fixed under bash at some time, however, it persists in windows environments.
Steps To Reproduce
- Use the script provided above
- Run sample commands
Environment
- npm: 10.8.2
- Node.js: v20.18.0 and v22.8.0 (managed with nvm-windows)
- OS Name: Windows 11
- System Model Name: Custom Desktop PC
- Terminal: Windows Terminal
- Shell: PowerShell 7.4.5
- npm config:
//registry.npmjs.org/:_authToken = (protected)