Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error occurs when executing npm scripts and npx when script-shell=pwsh.exe is specified in .npmrc #5332

Open
2 tasks done
JichouP opened this issue Aug 21, 2022 · 5 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@JichouP
Copy link

JichouP commented Aug 21, 2022

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

  1. Run npm config set script-shell pwsh.exe
  2. Run npm run <script> in any Node.js project. Or run npx, npx create-next-app, npm create tauri-app, etc.
  3. 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.
@JichouP JichouP added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 21, 2022
@JichouP
Copy link
Author

JichouP commented Aug 21, 2022

It seems to be related to PR #5297.

@kwburnett
Copy link

kwburnett commented Sep 19, 2022

I might've been doing something wrong, but even when I downgraded npm to version 7.24.0 and running on Node 18.9.0 I still received this error. I've installed Node via winget, so I had to follow the NPM instructions upgrade instructions to change the NPM version.

Anyways, I started downgrading Node and found that 18.3.0 with npm version 8.11.0 no longer has issue. I know you're on version 16.16.0, so this may be of little help. Maybe it's something to do with both the npm and Node working in conjunction? Not sure.

@Hellaeh
Copy link

Hellaeh commented Sep 19, 2022

Been having the same issue for a while. Downgrading to npm 8.12 helps for me. node version doesn't seem to affect the bug.

@drakonkat
Copy link

Any news on this?

@di-ma-73
Copy link

Removing ~/.npmrc file helps me out.
NPM (@latest and @next-9) installs packages correctly without that error about pwsh -c --.

Anyway, you can remove script-shell and shell lines from npmrc and check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

5 participants