Skip to content

[Windows] Spawning npm/npx opens npm.ps1 in Notepad instead of executing (nvm .ps1 shims) #50040

Description

@ramagdev

Symptom

On Windows, every time opencode runs npm (or npx), a Notepad window pops up showing the contents of npm.ps1 instead of (or in addition to) executing the command. Affects both TUI and webchat, since both share the same spawn path.

Environment

  • OS: Windows 11
  • Node via nvm4w (C:\nvm4w\nodejs\), npm 11.6.2
  • opencode TUI + opencode web

Root cause (verified on my machine)

  1. The nvm Node dir ships PowerShell shims next to the .cmd ones: npm.ps1 + npm.cmd (+ npx.ps1 + npx.cmd).
  2. opencode (Bun runtime) resolves npm to npm.ps1 and launches it through the Windows shell open verb.
  3. The machine-level .ps1 association is empty (HKCR\.ps1 has no default), and the per-user UserChoice points .ps1 at the Store Notepad (Microsoft.WindowsNotepad_...). So Windows opens the shim source in Notepad.

Workaround

Rename npm.ps1/npx.ps1 to .bak so resolution falls through to npm.cmd/npx.cmd (verified: Get-Command npm -> npm.cmd, both --version work, no Notepad). Reversible.

Suggested fix

On Windows, executable resolution for spawn should prefer .cmd/.exe over .ps1, or invoke .ps1 explicitly via powershell -File. Possibly same family as #17616 (Bun spawn mishandling PowerShell on Windows).

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