anomalyco / anomalyco/opencode

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

Open
#50,040 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Windows executable-resolution spawn path shared by the TUI and webchat, then reproduce with the npm and npx nvm4w shims. Done means .cmd or .exe is preferred over .ps1, or .ps1 is invoked explicitly through PowerShell, with both commands executing without opening Notepad.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, nodejs, powershell, typescript
Domain
cli, operating-systems, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.