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] Run requires double dash (--) twice to bypass parameters #6041

Closed
2 tasks done
aspirinv opened this issue Jan 11, 2023 · 3 comments
Closed
2 tasks done

[BUG] Run requires double dash (--) twice to bypass parameters #6041

aspirinv opened this issue Jan 11, 2023 · 3 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@aspirinv
Copy link

aspirinv commented Jan 11, 2023

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

Bypassing parameters requires double dash (--) repeated twice.

npm run start -- --configuration=development
> double-double-dash@0.0.0 start
> ng serve

npm run start -- -- --configuration=development
> double-double-dash@0.0.0 start
> ng serve --configuration=development

Expected Behavior

No response

Steps To Reproduce

Reproduce with angular:

  1. ng new double-double-dash
  2. cd double-double-dash
  3. npm run start -- --configuration=development
  4. npm run start -- -- --configuration=development

Environment

  • npm: 9.2.0
  • Node.js: 18.12.1
  • OS Name: Windows 10
  • npm config:
; "builtin" config from C:\Users\as980206\AppData\Roaming\npm\node_modules\npm\npmrc

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

; "global" config from C:\Users\as980206\AppData\Roaming\npm\etc\npmrc

python = "C:\\Users\\as980206\\.windows-build-tools\\python27\\python.exe"

; "user" config from C:\Users\as980206\.npmrc

//registry.npmjs.org/:_authToken = (protected)

; "cli" config from command line options

location = "project"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v18.12.1
; npm local prefix = D:\Projects\Temp\double-double-dash
; npm version = 9.2.0
; cwd = D:\Projects\Temp\double-double-dash
; HOME = C:\Users\as980206
; Run `npm config ls -l` to show all defaults.
@aspirinv aspirinv added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Jan 11, 2023
@fritzy
Copy link
Contributor

fritzy commented Jan 11, 2023

I'm not able to reproduce this with a minimal example. It sounds like something that the angular project may be doing.

❯ npm start -- --thingy

> test9@1.0.0 start
> node thingy.js --thingy

[
  '/usr/local/Cellar/node/19.0.1/bin/node',
  '/Users/fritzy/projects/scratchpad/test9/thingy.js',
  '--thingy'
]

If you can reproduce this with a minimum example, please reopen.

@fritzy fritzy closed this as completed Jan 11, 2023
@aspirinv
Copy link
Author

Thanks for reply. Just checked.
It appears to be a PowerShell issue.
Sorry for not taking this into consideration

@fvoronin
Copy link

I'll add. The reason for this behaviour is that when you call from PowerShell (unlike from cmd.exe), the command name npm resolves to a PowerShell script, namely npm.ps1.

When PowerShell calls a PowerShell-native command - including .ps1 files - its own parameter binder interprets the (first) -- argument and removes it; that is, the target command never sees it. (The semantics of -- is analogous to that of Unix utilities: -- tells the parameter binder to treat subsequent arguments as positional ones, even if they look like parameter (option) names, such as -foo)

Thus, unfortunately, you need to specify -- twice in order to pass a single -- instance through to the .ps1 script itself.

Alternatively, assuming that npm.cmd, i.e. a batch file version of the CLI exists too, you can bypass this problem by calling it explicitly, instead of the .ps1; when calling external programs (including scripts interpreted by other shells / scripting engines, such as cmd.exe), PowerShell does not remove --:

npm.cmd run start -- --configuration=development

undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Dec 4, 2024
Key changes:

- Upgrade npm dependencies to their latest
- Upgrade python dependencies to their latest
- Upgrade Node to 22 as 20 is end-of-life since October 2024

Other supporting changes:

- Refactor `assert` with `with` (see nodejs/node#51622)
- Centralize python setup via custom action for consistency
- Specify bash shell for correct argument handling on Windows using
  latest npm (npm/cli#6041)
undergroundwires added a commit to undergroundwires/privacy.sexy that referenced this issue Dec 4, 2024
Key changes:

- Upgrade npm dependencies to their latest
- Upgrade python dependencies to their latest
- Upgrade Node to 22 as 20 is end-of-life since October 2024

Other supporting changes:

- Refactor `assert` with `with` (see nodejs/node#51622)
- Centralize python setup via custom action for consistency
- Specify bash shell for correct argument handling on Windows using
  latest npm (npm/cli#6041)
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 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

3 participants