Skip to content

Windows: global cmd bin shadows System32 cmd.exe and hijacks every cmd /c call #1184

Backlog

Description

@ubranch

Summary

On Windows, npm i -g command-code installs a global bin named cmd (cmd, cmd.cmd, cmd.ps1).
Because the npm global bin directory usually comes before C:\Windows\System32 in the user PATH, this shadows the system cmd.exe.

Any program that starts cmd /c ... through PATH lookup then launches Command Code instead of the Windows shell.

Observed result

A console window titled command-code opened on its own with:

error: too many arguments. Expected 1 argument but got 14.

Another tool on the machine had run cmd /c <its command>, and PATH resolved cmd to the Command Code shim.

> where.exe cmd
C:\Users\<user>\AppData\Local\mise\installs\node\24.21.0\cmd
C:\Users\<user>\AppData\Local\mise\installs\node\24.21.0\cmd.cmd
C:\Users\<user>\AppData\Local\mise\shims\cmd.exe
C:\Windows\System32\cmd.exe

The same happens with a plain npm global prefix (%APPDATA%\npm), which Node installers put in the user PATH.

Environment

  • Windows 11, Node 24.21.0 (mise), npm global install
  • command-code@1.53.0

Expected

Installing a CLI must not replace a core OS executable. cmd is the Windows command processor.

Suggested fix

  • Do not ship the cmd bin on Windows (keep cmdc / command-code / commandcode), or drop cmd from package.json#bin entirely.
  • At minimum, warn during install on win32 and document the conflict.

Workaround: delete cmd, cmd.cmd, cmd.ps1 from the npm global bin dir, or uninstall the package.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions