Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Having a .npmrc that sets script-shell to 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
- Use Ubuntu with node v24.12.0 and npm 11.6.2 (alternatively: use Github Actions runner with
ubuntu-24.04 runner)
- Create
.npmrc file in a directory
- Open a bash in this directory
- Execute
npx protoc --ts_out ./gen
- (Agree to install
protoc)
- 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.