Skip to content

[BUG] -- parameters like --ts_out no longer work with npx in npm 11 compared to npm 10 when using pwsh script-shell in Ubuntu and produce Unexpected token in expression or statement errors #8854

@ceisele-r

Description

@ceisele-r

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

Having a .npmrc that sets script-shell to pwsh:

script-shell=pwsh

...and executing a command like npx protoc --ts_out ./gen that contains a parameter with -- produces the error

ParserError: 
Line |
   1 |  "protoc" --ts_out ./gen
     |             ~~~~~~
     | Unexpected token 'ts_out' in expression or statement.

in npm 11 where the same command is working in npm 10.

Expected Behavior

Executing a command like npx protoc --ts_out ./gen that contains a parameter with -- still works in npm 11 when using pwsh as script-shell (set via .npmrc).

Steps To Reproduce

  1. Use Ubuntu with node v24.12.0 and npm 11.6.2 (alternatively: use Github Actions runner with ubuntu-24.04 runner)
  2. Create .npmrc file in a directory
script-shell=pwsh
  1. Open a bash in this directory
  2. Execute npx protoc --ts_out ./gen
  3. (Agree to install protoc)
  4. See the error
ParserError: 
Line |
   1 |  "protoc" --ts_out ./gen
     |             ~~~~~~
     | Unexpected token 'ts_out' in expression or statement.

Now, switch back to npm 10:
8. npm i -g npm@10
9. Execute npx protoc --ts_out ./gen
10. The command is executed successfully without the Unexpected token error

Environment

  • npm: 11.6.2
  • Node.js: 24.12.0
  • OS Name: Ubuntu
  • System Model Name: Github Actions / VM
  • npm config:
; "user" config from /home/user/.npmrc

; script-shell = null ; overridden by project

; "project" config from /home/user/Desktop/testc/.npmrc

script-shell = "pwsh"

; node bin location = /home/user/.nvm/versions/node/v24.12.0/bin/node
; node version = v24.12.0
; npm local prefix = /home/user/Desktop/testc
; npm version = 11.6.2
; cwd = /home/user/Desktop/testc
; HOME = /home/user
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions