# Installing opencode with pnpm

**URL:** https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105
**Category:** Help
**Created:** [January 9, 2026, 11:03am UTC](https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105 "2026-01-09T11:03:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![neex](https://discourse.nixos.org/user_avatar/discourse.nixos.org/neex/32/37238_2.png) [@neex](https://discourse.nixos.org/u/neex)
#### Post date: [January 9, 2026, 11:03am UTC](https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105/1 "2026-01-09T11:03:43Z")

</div>

I installed opencode with pnpm:

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

```

But when I run it, I get this error:

```auto
$ 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?

---

<div class="post-metadata">

### Author: ![knoopx](https://discourse.nixos.org/user_avatar/discourse.nixos.org/knoopx/32/27641_2.png) [@knoopx](https://discourse.nixos.org/u/knoopx)
#### Post date: [January 9, 2026, 1:59pm UTC](https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105/2 "2026-01-09T13:59:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![neex](https://discourse.nixos.org/user_avatar/discourse.nixos.org/neex/32/37238_2.png) [@neex](https://discourse.nixos.org/u/neex)
#### Post date: [January 9, 2026, 2:46pm UTC](https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105/3 "2026-01-09T14:46:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Andrei](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/a/9fc29f/32.png) [@Andrei](https://discourse.nixos.org/u/Andrei)
#### Post date: [January 9, 2026, 2:49pm UTC](https://discourse.nixos.org/t/installing-opencode-with-pnpm/74105/4 "2026-01-09T14:49:25Z")

</div>

home-manager/opencode.nix

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