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
- 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 OPversions 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?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.
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?console.log(process.version) in your code
or simply node --version as it should keep it on runtime
That's how I got the version to begin with 😛
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?
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
Also, I may point out that discordjs/voice itself won't work on Bun due to leak of dgram support per part of Bun
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
this is the working "in-prod" state
Seems fine, that is with npm, right?
this is with yarn
And with npm?
I nuked node_modules now, waiting for npm to install...
Sure
well, this seems the same doesn't it
Correct. Also, could you be a little more descriptive of the issue when using with npm? I didn't quite understand
Well, now I'm very much wary that the whole thing will just work this time xD
LMAO
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
You probably would want to use static imports instead for commands, etc
but anyway the error was like "can't find this long ass path for Prism, cannot find opusscript either, cannot find node-opus either"
Hmmmm, it would be interesting if you tried again
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
Please mark it as solved :blobguns:
Np, if you have further issues, just create a post and we'll help ya