Why does @discordjs/opus only build properly with yarn?

Hello, I'm not sure how much this is an "issue" because I mostly used yarn anyway but I noticed when I tried to switch to Bun that neither with Bun's built-in package manager, nor with npm, @discordjs/opus is not really built, and I get a runtime error repording that the built version is missing, along with opusscript and node-opus. Is there something weird going on or is this a known thing? I really wonder because unlike npm, yarn has a "linking stage" for a couple of my native dependencies so it seems like npm just downright doesn't do something necessary.
26 Replies
d.js toolkit
d.js toolkit9mo 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! - Marked as resolved by OP
Nemokosch
NemokoschOP9mo ago
versions are 0.16.1 for @discordjs/voice, 10.2.4 for npm, 1.22.21 for yarn, v20.11.1 for node if that matters the point is exactly that it works only with yarn here, npm, yarn and bun are all package managers, the runtime could be Node all the time (although Bun should be Node compatible as a runtime) Bun as a package manager can indeed invoke node-gyp - but let's not digress too much I didn't even give a Bun version, it's completely besides the point take said version of Node and said version of npm, @discordjs/voice will pretend to be installed but the first time audio should be played, there will be a resolution error, not finding either the binary for it, or opusscript do the same with said version of yarn instead of npm and it will spend some time on the linking even at the installation - which npm didn't and the result is that it will indeed work I can send my package.json. Is there anything specific that needs to be set up for it to work with package managers other than yarn?
Nemokosch
NemokoschOP9mo ago
GitHub
rad.io/package.json at debug · 2colours/rad.io
Rad.IO discord bot project. Contribute to 2colours/rad.io development by creating an account on GitHub.
Nemokosch
NemokoschOP9mo ago
Well that's what I said It does pretend to be installed But it will explode at the first voice-related call unless you installed it with yarn If that really makes a difference, this happens on Debian 12 Bookworm, x64 then really, what is the difference. What platform do you use? Also, how long did the installation take? As I said, the whole thing was very suspicious because yarn has a linking stage which takes a couple of seconds while with npm it was very immediate with no visible step ^ 10.2.4... How could I check that?
ThePedroo
ThePedroo9mo ago
console.log(process.version) in your code or simply node --version as it should keep it on runtime
Nemokosch
NemokoschOP9mo ago
That's how I got the version to begin with 😛
ThePedroo
ThePedroo9mo ago
Nvm, it's impossible to fallback to v10 ES6 was only default on introduced to v16 Can you reproduce this issue by cloning your repo on a different folder, npm i and running?
d.js docs
d.js docs9mo ago
:guide: Getting Started: Introduction - Debugging Dependencies read more
Nemokosch
NemokoschOP9mo ago
right now I probably won't be able to actually drive the bot but I'm going to run this first with the "in-prod" state of things, then nuke node_modules, reinstall with npm and run again
ThePedroo
ThePedroo9mo ago
Also, I may point out that discordjs/voice itself won't work on Bun due to leak of dgram support per part of Bun
Nemokosch
NemokoschOP9mo ago
yes, eventually it doesn't work with Bun as a runtime, dgram is badly missing for a lot of things but then I was like "okay, how about I don't need yarn anymore anyway" it took me quite some time to even assume that the difference is yarn vs npm
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
this is the working "in-prod" state
ThePedroo
ThePedroo9mo ago
Seems fine, that is with npm, right?
Nemokosch
NemokoschOP9mo ago
this is with yarn
ThePedroo
ThePedroo9mo ago
And with npm?
Nemokosch
NemokoschOP9mo ago
I nuked node_modules now, waiting for npm to install...
ThePedroo
ThePedroo9mo ago
Sure
Nemokosch
NemokoschOP9mo ago
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
--------------------------------------------------
Core Dependencies
- @discordjs/voice: 0.16.1
- prism-media: 1.3.5

Opus Libraries
- @discordjs/opus: 0.9.0
- opusscript: not found

Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: 0.7.13
- tweetnacl: not found

FFmpeg
- version: 6.0-static https://johnvansickle.com/ffmpeg/
- libopus: yes
--------------------------------------------------
well, this seems the same doesn't it
ThePedroo
ThePedroo9mo ago
Correct. Also, could you be a little more descriptive of the issue when using with npm? I didn't quite understand
Nemokosch
NemokoschOP9mo ago
Well, now I'm very much wary that the whole thing will just work this time xD
ThePedroo
ThePedroo9mo ago
LMAO
Nemokosch
NemokoschOP9mo ago
Anyway, the point was that this whole audio part uses a lot of dynamic resolution so the mere fact that it "installed" means nothing if it won't find the binary I wonder if I still have the logs I think those logs already rolled out
ThePedroo
ThePedroo9mo ago
You probably would want to use static imports instead for commands, etc
Nemokosch
NemokoschOP9mo ago
but anyway the error was like "can't find this long ass path for Prism, cannot find opusscript either, cannot find node-opus either"
ThePedroo
ThePedroo9mo ago
Hmmmm, it would be interesting if you tried again
Nemokosch
NemokoschOP9mo ago
This is great, it works now did I really just forget to properly nuke the package store before installing with npm... at this point I lean towards something similarly banal 🤦‍♂️ the takeaway is always aim to reproduce an issue before publishing it sorry for the inconvenience
ThePedroo
ThePedroo9mo ago
Please mark it as solved :blobguns: Np, if you have further issues, just create a post and we'll help ya
Want results from more Discord servers?
Add your server