Skip to content

[BUG] when installing npm npm.ps1 is generated, ps1 files don't handle -- as expected! #4903

Description

@AnderssonPeter

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

If I run npm run test -- --value '10' the npm.ps1 file removes the -- this in turn removes all parameters that start with --.

 > npm run test -- --value '10'

> test@0.0.0 test
> node test.js "10"

if I remove npm.ps1 powershell instead executes npm.cmd and everything works as expected.

npm run test -- --value '10'

> test@0.0.0 test
> node test.js "--value" "10"

I am using PowerShell 7.2.3

The only workaround besides deleting npm.ps1 is to add quotes around the --.

Expected Behavior

The -- should be passed to npm so that argument parsing works as intended.

Steps To Reproduce

  1. Install node
  2. Upgrade to latest npm with npm install -g npm
  3. Ensure that you have a npm script named test that runs a node file example "test": "node test.js".
  4. Run 'npm run test -- --value '10'`
  5. See error...

Environment

  • npm: 8.10.0
  • Node.js: 18.1.0 or 16.15.0
  • OS Name: Windows 10
  • System Model Name: ???
  • npm config:
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v18.1.0
; npm local prefix = T:\eslint-issue
; npm version = 8.10.0
; cwd = T:\eslint-issue
; HOME = D:\Users\Peter
; Run `npm config ls -l` to show all defaults.```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releaseplatform:windowsis Windows-specific

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions