npm / npm/cli

[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

Open
#8,854 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with npm 11 on Ubuntu using a project .npmrc containing script-shell=pwsh, then compare the same npx protoc --ts_out ./gen command with npm 10. Trace the npx command execution path and shell argument handling; done means --ts_out ./gen executes successfully under npm 11 without the PowerShell parser error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.