randomuser922
randomuser922

Reputation: 147

node_modules/@discordjs/opus/prebuild/node-v83-napi-v3-win32-x64-unknown-unknown/opus.node: invalid ELF header

So I'm making a Discord Bot that relays audio from one voice channel to another, and I ran into a bug. Console said it couldn't find the opus.node file since I'm hosting the bot off of GitHub. So I changed the module_path value in node_modules/@discordjs/opus/package.json to exactly the path. It then said I had to add a substitution string for napi_build_version, so I did. Then it gave me another error saying that there was an invalid ELF header, and that it couldn't find node-opus or opusscript.

node_modules/@discordjs/opus/prebuild/node-v83-napi-v3-win32-x64-unknown-unknown/opus.node: invalid ELF header
(a few console.log lines not from errors)
Error: Cannot find module 'node-opus'
(some other error lines)
Error: Cannot find module 'opusscript'

Below is the code that I think the error is originating from.

function record(userid, connection){
    const audio = connection.receiver.createStream(userid, {end: 'manual', type: 'opus'})
    const playlist = connection.play(audio, { type: 'opus' })
}

Where I'm running the function from:

voiceChannel.members.forEach((member) => {
        if (member.id !== client.user.id && !ignore.includes(member.id)){
             record(member.id, connection);
        }
    })

and what the variables' values are:

const voiceChannel = message.member.voice.channel;
const connection = await voiceChannel.join();

Note: I can't run code in the GitHub Console(the console is just a log) If you have any questions please ask.

Upvotes: 0

Views: 2110

Answers (1)

randomuser922
randomuser922

Reputation: 147

I fixed my problem by adding

- run: npm install @discordjs/opus

to the .yml file above the

- run: node index.js

This way it installs the module for the system it uses.

Upvotes: 1

Related Questions