npm / cli

the package manager for JavaScript

Home Page:https://docs.npmjs.com/cli/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] `npm.ps1` introduced two regressions

liuxingbaoyu opened this issue · comments

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

npm.ps1 introduced two regressions.

  1. There is an encoding error when the username is non-ascii
  2. When C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js does not exist, it does not fall back to C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js. Fixed in latest
node:internal/modules/cjs/loader:1205
  throw err;
  ^

Error: Cannot find module 'C:\Users\娴佹槦鏆撮洦\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
    at Module._load (node:internal/modules/cjs/loader:1027:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v22.0.0

When I added $OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8 to fix the encoding issue

PS F:\git\node-js-max_path-windows-bug> npm.ps1
node:internal/modules/cjs/loader:1205
  throw err;
  ^

Error: Cannot find module 'C:\Users\流星暴雨\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
    at Module._load (node:internal/modules/cjs/loader:1027:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:187:14)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v22.0.0

Expected Behavior

suceess

Steps To Reproduce

  1. Run npm.ps1 on a Windows machine with a non-ascii username.
  2. See error...

Environment

  • npm: 10.5.1
  • Node.js: v22.0.0
  • OS Name: Windows 11
  • System Model Name:
  • npm config:
; "builtin" config from C:\Program Files\nodejs\node_modules\npm\npmrc

prefix = "C:\\Users\\流星暴雨\\AppData\\Roaming\\npm"

; "global" config from C:\Users\流星暴雨\AppData\Roaming\npm\etc\npmrc

python = "C:\\Python27\\python.exe"

; "user" config from C:\Users\流星暴雨\.npmrc

//registry.npmjs.org/:_authToken = (protected)
strict-ssl = false

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v22.0.0
; npm local prefix = F:\git\node-js-max_path-windows-bug
; npm version = 10.5.1
; cwd = F:\git\node-js-max_path-windows-bug
; HOME = C:\Users\流星暴雨
; Run `npm config ls -l` to show all defaults.