opencode --version fails during Docker build because opencode-ai's postinstall script isn't executed by npm install -g.
Error: opencode-ai's postinstall script was not run.
This occurs when using --ignore-scripts during installation, or when using a
package manager like pnpm that does not run postinstall scripts by default.
Seen in Renovate PR #23 (bumping opencode-ai to 1.17.18): CI run #3953
Fix
Explicitly run the postinstall script after npm install -g:
This ensures opencode --version works regardless of whether the base image's npm configuration ignores scripts.
## Problem
`opencode --version` fails during Docker build because `opencode-ai`'s postinstall script isn't executed by `npm install -g`.
```
Error: opencode-ai's postinstall script was not run.
This occurs when using --ignore-scripts during installation, or when using a
package manager like pnpm that does not run postinstall scripts by default.
```
Seen in Renovate PR #23 (bumping opencode-ai to 1.17.18): [CI run #3953](https://scm.cabillot.eu/perso/opencode/actions/runs/3953)
## Fix
Explicitly run the postinstall script after `npm install -g`:
```dockerfile
npm install -g --no-fund --no-audit opencode-ai@1.17.13 n2-soul@9.0.9 && \
cd /usr/local/lib/node_modules/opencode-ai && node postinstall.mjs && \
npm cache clean --force
```
This ensures `opencode --version` works regardless of whether the base image's npm configuration ignores scripts.
The node:24-trixie base image has npm configured with a restricted
allowScripts list, preventing opencode-ai's postinstall from running.
Pass --allow-scripts=opencode-ai,better-sqlite3 to npm install -g to
explicitly allow these packages to run their install scripts.
This is the npm-recommended fix as shown in the npm warning message.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
opencode --versionfails during Docker build becauseopencode-ai's postinstall script isn't executed bynpm install -g.Seen in Renovate PR #23 (bumping opencode-ai to 1.17.18): CI run #3953
Fix
Explicitly run the postinstall script after
npm install -g:This ensures
opencode --versionworks regardless of whether the base image's npm configuration ignores scripts.1722e0bfadtobc7d0580acbc7d0580acto9160870ae29160870ae2to247e0cf00b247e0cf00bto85c10f908b85c10f908bto7dc7c4a043