Installing opencode with pnpm

I installed opencode with pnpm:

$ pnpm i -g opencode-ai@latest
$ pnpm approve-builds -g

But when I run it, I get this error:

$ opencode
~/.local/share/pnpm/global/5/.pnpm/opencode-linux-x64@1.1.8/node_modules/opencode-linux-x64/bin/opencode:1
ELF
^

SyntaxError: Invalid or unexpected token
    at wrapSafe (node:internal/modules/cjs/loader:1692:18)
    at Module._compile (node:internal/modules/cjs/loader:1735:20)
    at Object..js (node:internal/modules/cjs/loader:1893:10)
    at Module.load (node:internal/modules/cjs/loader:1481:32)
    at Module._load (node:internal/modules/cjs/loader:1300:12)
    at TracingChannel.traceSync (node:diagnostics_channel:328:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
    at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
    at node:internal/main/run_main_module:33:47

Node.js v24.11.1

How can I fix this error, without installing opencode from nix packages?

1 Like

i just run bunx opencode-ai, it updates so frequently that’s not really worth “installing” it

I think bunx opencode-ai does not build the “binaries” that pnpm approve-builds -g does.

home-manager/opencode.nix

{ pkgs, … }:

{
home.packages = with pkgs; [
nodejs
(writeShellApplication {
name = “opencode”;
text = ‘’
exec ${nodejs}/bin/npx opencode-ai@latest “$@”
‘’;
})
];
}