anomalyco / anomalyco/opencode
# Bug Report: Windows launcher (`bin/opencode.exe`) is invalid when installed with npm 12 + nvm4w
@Hona is already working on this.
Since Jul 30, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Summary
On Windows x64, installing opencode-ai globally with npm results in a broken launcher.
The launcher located at:
<node-global>\node_modules\opencode-ai\bin\opencode.exe
is only 479 bytes and Windows reports:
"The specified executable is not a valid application for this operating system platform."
However, the native binary works correctly once it is installed manually.
Environment
- OS: Windows 11 x64
- Node.js: v24.16.0
- npm: 12.0.2
- Node manager: nvm4w
- Installation method:
npm install -g opencode-ai --allow-scripts=opencode-ai
Installed package version:
opencode-ai 1.18.8
Expected behavior
Running
opencode
or
opencode --version
should start OpenCode normally.
Actual behavior
PowerShell returns:
The program 'opencode.exe' failed to run:
The specified executable is not a valid application for this operating system platform.
The failing executable is:
C:\nvm4w\nodejs\node_modules\opencode-ai\bin\opencode.exe
File size:
479 bytes
Investigation
The launcher generated by the package is invalid.
Initially, the package did not install any of its optional native dependencies.
Running:
Get-ChildItem "C:\nvm4w\nodejs\node_modules\opencode-ai\node_modules"
returned nothing.
The package.json correctly declares:
"optionalDependencies": {
"opencode-windows-x64": "1.18.8",
...
}
but the dependency was not installed automatically.
After manually installing:
npm install -g opencode-windows-x64@1.18.8
the native executable became available at:
C:\nvm4w\nodejs\node_modules\opencode-windows-x64\bin\opencode.exe
Running:
opencode.exe --version
returns:
1.18.8
which proves the native binary itself works correctly.
Additional observation
The launcher scripts generated by npm (opencode.cmd and opencode.ps1) always invoke:
node_modules\opencode-ai\bin\opencode.exe
Since this executable is invalid, every invocation of:
opencode
fails.
If the launcher is manually modified to invoke the real native binary instead, OpenCode works correctly.
Possible root cause
It appears one of the following is happening:
-
npm 12 + nvm4w is not installing the optional dependency
opencode-windows-x64, or -
postinstall.mjsis not handling this installation scenario correctly, leavingbin/opencode.exeunusable.
Suggested improvements
- Verify compatibility with npm 12.
- Detect when the native package is missing and display a clear error.
- Automatically resolve the native executable from the installed optional dependency.
- Consider avoiding the current 479-byte launcher if it cannot execute correctly on Windows.
Reproduction steps
- Install Node.js using nvm4w.
- Use npm 12.x.
- Run:
npm install -g opencode-ai
(or even)
npm install -g opencode-ai --allow-scripts=opencode-ai
- Run:
opencode
The launcher fails with the Windows executable error.
Temporary workaround
npm install -g opencode-windows-x64
Then invoke the native executable directly:
node_modules/opencode-windows-x64/bin/opencode.exe
instead of the generated launcher.
Thank you for your work on OpenCode. If you need any additional logs or if you'd like me to test a fix on Windows (npm 12 + nvm4w), I'd be happy to help.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
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.
Assessment
This issue has not been assessed yet.