[BUG] Error occurs when executing npm scripts and npx when script-shell=pwsh.exe is specified in .npmrc
Open
Nobody has claimed this yet.
Bug
Needs Triage
Release 8.x
- 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
E:\workspace>npx
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Entering npm script environment at location:
E:\workspace
Type 'exit' or ^D when finished
ParserError:
Line |
1 | -- pwsh.exe
| ~
| Missing expression after unary operator '--'.
Expected Behavior
Works fine if script-shell is set to cmd.exe.
E:\workspace>npm config set script-shell cmd.exe
E:\workspace>npx
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Entering npm script environment at location:
E:\workspace
Type 'exit' or ^D when finished
Microsoft Windows [Version 10.0.22000.856]
(c) Microsoft Corporation. All rights reserved.
E:\workspace>
Steps To Reproduce
- Run
npm config set script-shell pwsh.exe - Run
npm run <script>in any Node.js project. Or runnpx,npx create-next-app,npm create tauri-app, etc. - See error like this
ParserError:
Line |
1 | -- pwsh.exe
| ~
| Missing expression after unary operator '--'.
Environment
- npm: 8.18.0
- Node.js: 16.16.0
- OS Name: Microsoft Windows [Version 10.0.22000.856]
- System Model Name: MS-7D30
- Power Shell: 7.2.6
- npm config:
; "builtin" config from C:\Users\jichoup\AppData\Roaming\npm\node_modules\npm\npmrc
prefix = "C:\\Users\\jichoup\\AppData\\Roaming\\npm"
; "user" config from C:\Users\jichoup\.npmrc
//registry.npmjs.org/:_authToken = (protected)
script-shell = "pwsh.exe"
shell = "pwsh.exe"
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v16.16.0
; npm local prefix = E:\workspace
; npm version = 8.18.0
; cwd = E:\workspace
; HOME = C:\Users\jichoup
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with npm config set script-shell pwsh.exe, then run npm run <script> or npx on Windows and inspect the npm CLI paths handling script-shell. Done means npm scripts and npx launch successfully with pwsh.exe, without the PowerShell parser error, while the existing cmd.exe behavior remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100