Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Newlines are handled differently between node and npm exec on powershell #7830

Open
2 tasks done
rgembalik opened this issue Oct 12, 2024 · 0 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Priority 2 secondary priority issue

Comments

@rgembalik
Copy link

rgembalik commented Oct 12, 2024

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

  1. Use the script provided above
  2. 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)
@rgembalik rgembalik added Bug thing that needs fixing Needs Triage needs review for next steps labels Oct 12, 2024
@milaninfy milaninfy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Oct 18, 2024
@doni108108doni doni108108doni mentioned this issue Oct 19, 2024
2 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue
Projects
None yet
Development

No branches or pull requests

2 participants