anomalyco / anomalyco/opencode
[Windows] Spawning npm/npx opens npm.ps1 in Notepad instead of executing (nvm .ps1 shims)
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)
- The nvm Node dir ships PowerShell shims next to the
.cmdones:npm.ps1+npm.cmd(+npx.ps1+npx.cmd). - opencode (Bun runtime) resolves
npmtonpm.ps1and launches it through the Windows shell open verb. - The machine-level
.ps1association is empty (HKCR\.ps1has no default), and the per-userUserChoicepoints.ps1at 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
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.
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