[BUG] npx on Windows: bins with pnpm .cmd shims fail with MODULE_NOT_FOUND since #10044 quotes the executable name
Los mantenedores suelen responder en 2 días
@ultimate-kiran ya está trabajando en esto.
Desde el 25/11/2026.
- #10351 de @ultimate-kiran — abierto
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
Línea de trabajo
The cause is in libnpmexec/lib/run-script.js, where #10044 began quoting the executable name for cmd.exe. Reproduce on Windows by running npx against a bin whose shim uses %~dp0 directly, and compare the quoted and unquoted forms. A fix already has an open pull request (#10351), so review or test that work rather than starting a parallel change.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
On Windows, npx <bin> fails with MODULE_NOT_FOUND when the bin's .cmd shim in node_modules\.bin was written by pnpm. The shim looks for the package one folder too high:
PS C:\project\pkg> npx wrangler --version
npm notice run ^"wrangler^" --version
Error: Cannot find module 'C:\project\wrangler\bin\wrangler.js'
code: 'MODULE_NOT_FOUND'
The file is really at C:\project\pkg\node_modules\wrangler\bin\wrangler.js. This worked before the upgrade to npm 12.
Cause, as far as I can tell: #10044 made libnpmexec/lib/run-script.js quote the executable name for cmd.exe, so the script becomes "wrangler" --version. When cmd.exe starts a batch file by a quoted bare name found through PATH, and arguments follow, %~dp0 inside that batch file resolves to the current directory instead of the batch file's own folder. pnpm's shim runs node "%~dp0\..\wrangler\bin\wrangler.js", so it points at C:\project\pkg\..\wrangler\....
npm's own cmd-shim output is not affected because it reads %~dp0 through CALL :find_dp0. Shims written by other tools (pnpm, and anything else that uses %~dp0 directly) break.
The same quirk without npm, run from PowerShell 7 in C:\tmp\dp0, with C:\tmp\dp0\bin\showdir.cmd containing @echo %~dp0 and C:\tmp\dp0\bin on PATH:
cmd /d /s /c 'showdir a b' -> C:\tmp\dp0\bin\ (correct)
cmd /d /s /c '"showdir" a b' -> C:\tmp\dp0\ (current directory)
Expected Behavior
npx wrangler --version runs the bin from node_modules\.bin, as it did before npm 12.
Possible fixes: only quote the name when it contains cmd metacharacters, or resolve the bin to its absolute path before quoting it.
Steps To Reproduce
- On Windows, in a project installed with pnpm:
pnpm add -D wrangler(any package with abinshould do). - From PowerShell or cmd, run
npx wrangler --versionwith npm 12.2.3. - See
Cannot find module '<parent of project>\wrangler\bin\wrangler.js'.
pnpm exec wrangler --version works in the same folder. Workaround: setting npm_config_script_shell=pwsh makes npx use the .ps1 shim, which resolves its folder correctly.
Environment
- npm: 12.2.3
- Node.js: 24.15.0
- OS Name: Windows 11 Pro (10.0.26200)
- System Model Name: x64 desktop
- npm config: defaults (no
script-shellset) - Shims generated by pnpm 11.2.2
- Lenguaje dominante
- JavaScript
- Estrellas
- 10.3k
- Forks
- 5k
- Merge medio
- 4 d 11 h
- PR fusionados (30 d)
- 26
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de npm/cli
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 2 días
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsPosiblemente ocupada @saruk-vedant la tomó hace 7 días. AbiertoBug Needs Triage Triage Requested
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
npm/cli#10316 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyPosiblemente ocupada @drawliin la tomó hace 42 días. Abiertocmd:delete Priority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 2 días
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoEngineering Priority 1
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 2 días
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysPosiblemente ocupada @greenlincoln05 la tomó hace 63 días. AbiertoPriority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
npm/cli#10018 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
Issues similares
-
documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
githubnext/gh-aw-workshop#6332 ·
Los mantenedores suelen responder en 1 día
-
App Designer bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
avniproject/avni-webapp#1858 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 96/100
hiero-ledger/hiero-sdk-js#4834 ·
Los mantenedores suelen responder en 1 día
-
[组件名称] 描述问题的标题Abierto🐞 bug 🧐 unconfirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Tencent/tdesign-miniprogram#4744 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Y-axis tooltip hides near the bottom of the plot while the y crosshair stays visiblePosiblemente ocupada @lazerg la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apexcharts/apexcharts.js#5449 ·
Los mantenedores suelen responder en 3 días