#23337: fix: move @discordjs/opus to optionalDependencies [AI-assisted ๐ค]
size: XS
## Summary
- Problem: `npm install -g openclaw@latest` fails on x64/ARM/Docker with `EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus`
- Why it matters: Blocks clean installs on all common platforms (Linux x64, ARM, Docker) for users not using Discord voice features
- What changed: `@discordjs/opus` moved from `dependencies` โ `optionalDependencies` in `package.json` (1 line removed, 3 added)
- What did NOT change: Discord voice functionality is unaffected on platforms where a prebuilt binary exists; all other dependencies unchanged
## Change Type (select all)
- [x] Bug fix
## Scope (select all touched areas)
- [x] CI/CD / infra
## Linked Issue/PR
- Closes #22877
## User-visible / Behavior Changes
`npm install -g openclaw@latest` (and `pnpm install`) now succeeds on platforms without a prebuilt `@discordjs/opus` binary. Discord voice continues to work where binaries are available.
## Security Impact (required)
- New permissions/capabilities? No
- Secrets/tokens handling changed? No
- New/changed network calls? No
- Command/tool execution surface changed? No
- Data access scope changed? No
## Repro + Verification
### Environment
- OS: Linux x64 (Docker, WSL2)
- Runtime/container: Node 22, Docker multi-stage build
- Model/provider: N/A
- Integration/channel: N/A
### Steps
1. `npm install -g openclaw@latest` on a clean x64/ARM/Docker environment
2. Observe `EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus`
3. With this fix applied, install completes successfully
### Expected
Install completes without error
### Actual (before fix)
`EBUILDNOSUPPORT: No prebuilt binaries found for @discordjs/opus`
## Evidence
- [x] Trace/log snippets
`pnpm install` with fix applied:
```
โญ Warning โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Ignored build scripts: @discordjs/opus. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
Done in 36.3s using pnpm v10.23.0
```
`require('@discordjs/opus')` โ graceful runtime failure (no install abort):
```
Error: Cannot find module '...prebuild/node-v127-napi-v3-linux-x64-glibc-2.36/opus.node'
```
openclaw loads clean without opus:
```
import('./dist/index.js') โ loads ok โ
```
- `pnpm build` โ
`pnpm check` โ
(format, typecheck, lint all clean)
- `src/plugins/tools.optional.test.ts` โ 5/5 โ
- AI-assisted: built with Claude (running inside OpenClaw/Canopy). Prompts available on request.
- Degree of testing: lightly tested (unit + build + lint; full suite skipped โ metadata-only change, CI will cover)
## Human Verification (required)
Verified on: Linux x64, Node v22.22.0, Docker (WSL2)
- `pnpm install` completed โ opus build scripts skipped (confirmed via pnpm warning)
- No prebuilt binary present (`opus.node` missing for `node-v127-napi-v3-linux-x64-glibc-2.36`)
- `require('@discordjs/opus')` produces graceful runtime `MODULE_NOT_FOUND` โ install-time failure eliminated
- `import('./dist/index.js')` โ `loads ok โ
` โ openclaw runs without opus present
- Did NOT verify: ARM build, Discord voice on a platform with a valid prebuilt binary
To add: this seems like a low enough risk change with high reward to fix builds that are reported on multiple envs, I don't have the full development environment set up to test fully end to end, but I'm hoping contextually that's not an issue :)
## Compatibility / Migration
- Backward compatible? Yes
- Config/env changes? No
- Migration needed? No
## Failure Recovery (if this breaks)
- Revert: restore `@discordjs/opus` to `dependencies`, remove from `optionalDependencies` in `package.json`
- Known bad symptoms: Discord voice features unavailable on affected platforms (but those were already broken before this fix at install time)
## Risks and Mitigations
- Risk: platforms that previously failed loudly at install now silently skip opus
- Mitigation: Discord voice will fail at runtime with a clear missing-module error if used โ same outcome, shifted from install-time to runtime
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Moved `@discordjs/opus` from `dependencies` to `optionalDependencies` to fix install failures on platforms without prebuilt binaries (x64/ARM/Docker). The change is safe because:
- Discord voice code already implements a fallback chain: `opusscript` (primary, still in dependencies) โ `@discordjs/opus` (secondary, now optional) โ graceful degradation
- `createOpusDecoder()` in `src/discord/voice/manager.ts:149-170` handles missing decoders by returning `null`, which is checked before use
- Users without Discord voice features are unaffected; users with voice continue working via `opusscript` or where `@discordjs/opus` binaries are available
<h3>Confidence Score: 5/5</h3>
- Safe to merge - fixes install failures without breaking Discord voice functionality
- The change is a minimal, well-targeted fix with existing fallback mechanisms. The code already handles missing opus decoders gracefully via opusscript (which remains in dependencies), and the PR addresses a real blocking issue affecting multiple platforms.
- No files require special attention
<sub>Last reviewed commit: 8321db3</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17237: fix(update): guard post-install imports after npm global update
by tdjackey ยท 2026-02-15
78.7%
#23129: build(deps): move @discordjs/opus to optionalDependencies
by Imccccc ยท 2026-02-22
77.3%
#20055: fix(plugins): strip workspace:* dev-deps before npm install
by openperf ยท 2026-02-18
77.0%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW ยท 2026-02-19
76.6%
#8500: fix: Remove workspace:* from devDependencies in voice-call plugin
by ImBIOS ยท 2026-02-04
76.5%
#22692: fix(memory-lancedb): [P1] add missing runtime deps โ plugin broken ...
by mahsumaktas ยท 2026-02-21
76.2%
#19941: fix(nostr): move openclaw from devDependencies to peerDependencies
by AustinEral ยท 2026-02-18
76.1%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 ยท 2026-02-18
76.0%
#22557: fix(discord): coerce exec approval approver IDs to string to preven...
by zwffff ยท 2026-02-21
75.3%
#21463: fix(discord): prevent WebSocket death spiral + fix numeric channel IDโฆ
by akropp ยท 2026-02-20
75.1%