@discordjs/opus issue when rebuilding for electron

const { OpusEncoder } = require('@discordjs/opus')
...
/* decode raw OPUS packets into raw PCM/interleaved/signed-int16/little-endian data */
if (this.opusEncoder === null)
this.opusEncoder = new OpusEncoder(sampleRate, noChannels)
const decoded = this.opusEncoder.decode(buffer)
const { OpusEncoder } = require('@discordjs/opus')
...
/* decode raw OPUS packets into raw PCM/interleaved/signed-int16/little-endian data */
if (this.opusEncoder === null)
this.opusEncoder = new OpusEncoder(sampleRate, noChannels)
const decoded = this.opusEncoder.decode(buffer)
ERROR:
Uncaught Error Error: Cannot find module 'D:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\prebuild\electron-v25.7-napi-v3-win32-x64-unknown-unknown\opus.node'
Require stack:
- D:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\lib\index.js
- D:\Libraries\Documents\GitHub\tv-dinner\worker.html
at Module._resolveFilename (internal/modules/cjs/loader:1082:15)
at o._resolveFilename (electron/js2c/renderer_init:2:3879)
at Module._load (internal/modules/cjs/loader:927:27)
at f._load (electron/js2c/asar_bundle:2:13330)
at o._load (electron/js2c/renderer_init:2:3109)
at Module.require (internal/modules/cjs/loader:1148:19)
at require (internal/modules/cjs/helpers:110:18)
at <anonymous> (d:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\lib\index.js:5:18)
Uncaught Error Error: Cannot find module 'D:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\prebuild\electron-v25.7-napi-v3-win32-x64-unknown-unknown\opus.node'
Require stack:
- D:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\lib\index.js
- D:\Libraries\Documents\GitHub\tv-dinner\worker.html
at Module._resolveFilename (internal/modules/cjs/loader:1082:15)
at o._resolveFilename (electron/js2c/renderer_init:2:3879)
at Module._load (internal/modules/cjs/loader:927:27)
at f._load (electron/js2c/asar_bundle:2:13330)
at o._load (electron/js2c/renderer_init:2:3109)
at Module.require (internal/modules/cjs/loader:1148:19)
at require (internal/modules/cjs/helpers:110:18)
at <anonymous> (d:\Libraries\Documents\GitHub\tv-dinner\node_modules\@discordjs\opus\lib\index.js:5:18)
I rebuilt @discordjs/opus for electron using electron-rebuild and the app is searching for Opus.node in the wrong directory. The prebuild generated by the rebuild process is called .\node_modules@discordjs\opus\prebuild\electron-v25.7-napi-v3-win32-x64-unknown-{libc_version}. Meanwhile the app is searching in "unkown-unknown"
4 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
kurtosis
kurtosisOP16mo ago
opus version 0.9 node version 18.16.1
MaxJ
MaxJ16mo ago
Probably reinstall opus and see what that does
kurtosis
kurtosisOP16mo ago
Tried that multiple times and it’s still the same Deleted node_modules and ran npm install again
Want results from more Discord servers?
Add your server