[BUG] .cmd @echo off
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, nodejs
- Domain
- cli
Research direction
Reproduce the behavior in a Windows command prompt with npm.cmd, using the reported npm 8.12.2 and Node v16.14.2 environment. Compare the current npm.cmd behavior with the proposed batch-file change, then verify that npm -v exits normally and preserves the prompt's echo setting.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
this is similar to what is raised here (never resolved):
https://github.com/npm/npm/issues/19681
At a Windows command prompt running npm -v with npm@latest seems to hang.
Typing echo on brings back the prompt as described in the above bug.
This seems to contradict Microsoft documentation for @echo off, that remarks (to quote)
"If used in a batch file, echo on and echo off don't affect the setting at the command prompt."
I see this behaviour on Windows 10.
If I patch the npm.cmd file like this, it behaves well:
@SETLOCAL
@FOR /f "tokens=1,2,3 delims=. " %%G IN ('ECHO') DO @SET _echo=%%I
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
ENDLOCAL & (CALL) || TITLE %COMSPEC% & "%_prog%" "%dp0%\node_modules\npm\bin\npm-cli.js" %* & ECHO %_echo%
Expected Behavior
normal exit, no change to current prompt setting.
Steps To Reproduce
- Start cmd prompt
- Run
npm -vat the prompt - appears to hang,
echo onfixes
Environment
- npm: 8.12.2
- Node: v16.14.2
- OS: Windows
- platform: Microsoft Windows [Version 10.0.19044.1645]
- Dominant language
- JavaScript
- Stars
- 81
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from npm/cmd-shim
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
[BUG] PowerShell shim generated as UTF-8 without BOM breaks on Windows PowerShell 5 with non-ASCII pathsPossibly taken @webywz claimed this 32 days ago. OpenNeeds Triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Needs Triage
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Priority 1
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Needs Triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug has-work-around priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
liberation-data/drivine#908 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
JoeyHammoth/SolidGround#99 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Flow Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
react/react-native#60447 ·
Maintainers usually reply within 1 day