Repository navigation
Description
Description
On Windows, opencode plugin add / opencode plugin update fail for any git-spec plugin whose package.json defines one of build, prepare, prepack, install, preinstall, or postinstall:
NpmInstallFailedError
at Npm.reify ...
[cause]: Error: git dep preparation failed
Root cause (v2.1.4 bundles @npmcli/[email protected] + patched [email protected]; see packages/util/src/npm.ts):
- Plugin packages are installed via Arborist
reify. - pacote's git fetcher (
lib/git.js#prepareDir) runs in-clone preparation when the dep'spackage.jsondefines any of the script names above, and shells out to the barenpmCLI:npm(this.npmBin ?? "npm", ["install", "--force", ...], cloneDir). - On Windows
npmis a.cmdshim, and spawning it without a shell fails (observedENOENT, even with npm 11.12.1 on PATH). Arborist wraps that asgit dep preparation failed, OpenCode surfacesNpmInstallFailedError. So this fails regardless of whether node/npm are installed.
Instrumented spawn trace from a standalone reproduction using the same Arborist options as packages/util/src/npm.ts:
spawn ENOENT -> "npm" ["install","--force","--cache=...","--prefer-offline=false",
"--prefer-online=true",...,"--no-package-lock-only","--no-dry-run"]
cwd: ~\.npm\_cacache\tmp\git-clone*
macOS/Linux are likely unaffected (a real npm executable spawns fine if node is installed), so this is Windows-only.
Environment
- OpenCode version: 2.1.4 (release channel, installed via bun)
- OS: Windows 11 (10.0.26200, x64)
- Plugins: a git-spec TUI plugin installed via
opencode plugin add github:<owner>/<repo> - node 24.15.0 / npm 11.12.1 on PATH (not required for the failure)
Steps to reproduce
- On Windows, point
plugin addat a public git repo whosepackage.jsoncontains e.g."scripts": { "build": "echo ok" }(no actual build needed). opencode plugin add github:<owner>/<repo>→ fails withNpmInstallFailedError, causegit dep preparation failed.- Remove the
buildkey and push → the same command now succeeds (pacote skips prep and packs the clone via npm-packlist).
Expected
Git-spec plugins that define build scripts install successfully — prep skipped when unnecessary, or npm spawned in a Windows-safe way (e.g. process.execPath + npm-cli.js, or shell handling for .cmd shims).
Actual
Install fails consistently with the wrapped error above, before any of the plugin's code runs.
Workaround
Avoid all six script names in a git plugin's package.json (e.g. rename build → build:tui). Confirmed working.
Related but separate: #39986 (Solid JSX transform not applied to TUI plugins under node_modules).
Activity
opencode-agent commentedon Oct 27, 2026
Thanks for the detailed report and the spawn trace, they make this easy to follow.
I think this is a duplicate of #49704. That issue covers the same failure:
opencode plugin addwith a git spec fails withNpmInstallFailedError/git dep preparation failedwhenever the plugin'spackage.jsondefinesbuild,prepare,prepack,install,preinstallorpostinstall. Renaming the script is the workaround there too. In both cases the trigger is pacote's git preparation step, which runs a nestednpm installinside the clone. On your system that fails because the barenpm.cmdshim can't be spawned without a shell on Windows. #49704 has reports of it on macOS up to 2.1.3. OpenCode already installs plugins withignoreScripts: true, so the fix discussed there (skipping that preparation step for git deps) would cover Windows too.Possible duplicates and related issues, ordered by likelihood:
unable to resolve dependency tree), not this bugNpmInstallFailedErrorduring plugin install, with a different causeYour Windows details (the
ENOENTwhen spawningnpmand the 2.1.4 confirmation) would be a useful addition to #49704 as a comment.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
fix(install): rename build script to compile
fix(install): rename build script to compile