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

[BUG] When invoked from PowerShell prompt on Windows, positional arguments are not properly passed to NPM scripts #7440

Closed
2 tasks done
noseratio opened this issue Apr 29, 2024 · 1 comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x

Comments

@noseratio
Copy link

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

process.argv is missing CLI arguments.

Using Node.js v22.0.0, NPM v10.6.0 and PowerShell v7.4.2 on Windows 11.

package.js:

{
  "name": "cli-test",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  }
}

index.js:

console.dir(process.argv);

Running it from a PowerShell prompt:

PS C:\temp\cli-test> npm start -- command --arg=value

> [email protected] start
> node index.js command

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\temp\\cli-test\\index.js',
  'command'
]

Note how --arg=value is missing from process.argv.

Expected Behavior

--arg=value must be present in process.argv. It works properly if invoked from cmd (rather than PowerShell):

PS C:\temp\cli-test> cmd
Microsoft Windows [Version 10.0.22631.3527]
(c) Microsoft Corporation. All rights reserved.

C:\temp\cli-test>npm start -- command --arg=value

> [email protected] start
> node index.js command --arg=value

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\temp\\cli-test\\index.js',
  'command',
  '--arg=value'
]

It also works as expected under previous versions of Node v21.7.3 and NPM v10.5.0 and the same version of PowerShell v7.4.2.

Steps To Reproduce

See above in "Current Behavior".

Environment

  • npm: 10.6.0
  • Node.js: 22.0.0
  • OS Name: Windows 11 23H2 Build 22631.3527
  • System Model Name:
  • npm config:
; "builtin" config from C:\Users\User\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\User\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.0.0
; npm local prefix = C:\temp\cli-test
; npm version = 10.6.0
; cwd = C:\temp\cli-test
; HOME = C:\Users\User
; Run `npm config ls -l` to show all defaults.
@noseratio noseratio added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Apr 29, 2024
@wraithgar
Copy link
Member

Duplicate of #7375

@wraithgar wraithgar marked this as a duplicate of #7375 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x
Projects
None yet
Development

No branches or pull requests

2 participants