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] npm exec on Windows may fail depending on the shell codepage #5238

Closed
2 tasks done
yhatt opened this issue Jul 30, 2022 · 3 comments
Closed
2 tasks done

[BUG] npm exec on Windows may fail depending on the shell codepage #5238

yhatt opened this issue Jul 30, 2022 · 3 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

@yhatt
Copy link

yhatt commented Jul 30, 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

In npm v8.13.0 and earlier versions, npm exec may fail if executed in the Windows shell that have non-standard code page. I've received a feedback from the user of my Node tool who tried to use via npx: marp-team/marp-cli#465

Expected Behavior

npm exec should pass correct arguments to the command regardless of the shell codebase.

npm v8.12.2 and earlier versions had worked as that.

Steps To Reproduce

  1. Open cmd.exe.
  2. Run chcp 65001, to change the active code page of the current shell into UTF-8.
  3. Run npm exec echo-cli ö.
  4. See error...
> chcp 65001
Active code page: 65001

> npm exec echo-cli ö
'cho-cli' is not recognized as an internal or external command,
operable program or batch file.

This error can when using npm v8.13.0 and later. npm exec is working in v8.12.x correctly.

> npm install -g npm@8.12.2
> npm -v
8.12.2

> chcp 65001
> npm exec echo-cli ö
ö

Environment

  • npm: 8.15.1
  • Node.js: 18.7.0
  • OS Name: Windows 10 (10.0.19041 Build 19041)
  • System Model Name: Virtual Machine (Windows Sandbox)
  • npm config:
; "builtin" config from C:\Users\WDAGUtilityAccount\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\WDAGUtilityAccount\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v18.7.0
; npm local prefix = C:\Users\WDAGUtilityAccount
; npm version = 8.15.1
; cwd = C:\Users\WDAGUtilityAccount
; HOME = C:\Users\WDAGUtilityAccount
; Run `npm config ls -l` to show all defaults.
@yhatt yhatt 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 Jul 30, 2022
@nlf
Copy link
Contributor

nlf commented Aug 29, 2022

i'm not able to reproduce this in npm@8.18.0? i'm seeing it work consistently while testing it on a windows laptop. can you try updating and see if this problem resolves for you?

@yhatt
Copy link
Author

yhatt commented Aug 29, 2022

Confirmed it was fixed in npm@8.17.0 and later versions, including npm@8.18.0.

I guess the script execution through tmpfile had been influented by shell codepage, so I think npm/run-script#98 made a benefical result. 👍

@nlf
Copy link
Contributor

nlf commented Aug 29, 2022

excellent! thanks for confirming!

@nlf nlf closed this as completed Aug 29, 2022
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

2 participants