Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bun] Cannot find module "@discordjs/opus/prebuild/node-v115-napi-v3-linux-x64-glibc-2.29/opus.node" #154

Open
quangpao opened this issue May 2, 2024 · 0 comments
Labels
bug Something isn't working need repro

Comments

@quangpao
Copy link

quangpao commented May 2, 2024

Issue description

I can't use the package while using "Bun", which said to compatibility with Node.js v20.

I think Bun currently using node-v115-napi-v3-${OS}-glibc-2.29 as it primary. If this is the case, can we support this into the package?

Step to reproduce:

  1. Install @discordjs/opus:0.9.0 by command bun add @discordjs/opus
  2. Execute the function that using the @discordjs/opus
  3. Error pop-up:
See: https://distube.js.org/classes/DisTube.html#error and https://nodejs.org/api/events.html#events_error_events
[I] [InepEvents] Triggered |interactionCreate| event
  7 |       return data;
  8 |     } catch (e) {
  9 |       errorLog.push(e);
 10 |     }
 11 |   }
 12 |   throw new Error(errorLog.join('\n'));
              ^
PlayingError: ResolveMessage: Cannot find module "/app/node_modules/@discordjs/opus/prebuild/node-v115-napi-v3-linux-x64-glibc-2.29/opus.node" from "/app/node_modules/@discordjs/opus/lib/index.js"
 ResolveMessage: Cannot find package "node-opus" from "/app/node_modules/prism-media/src/util/loader.js"
 ResolveMessage: Cannot find package "opusscript" from "/app/node_modules/prism-media/src/util/loader.js"

Code sample

execute: async (interaction, client?: InepClient) => {
    const member = interaction.member as GuildMember;
    const channel = member.voice.channel;

    try {
      const query = interaction.options.getString("song", true);
      const distube = client?.distube as InepTube;

      await interaction.reply({
        content: `🎵 Searching for \`${query}\`...`,
        ephemeral: true,
      });
      //This is where the error occured
      await distube.play(channel as VoiceBasedChannel, query, {
        textChannel: interaction.channel as GuildTextBasedChannel,
        member,
      });
    } catch (error) {
      logger.error(error);
    }
  },
# OVEN - BUN Official Image
FROM oven/bun:slim as base
WORKDIR /app
RUN apt-get update && apt-get install -y \
    build-essential \
    libtool \
    automake \
    python3 \
    ffmpeg \
    curl \
    && rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash -
RUN apt-get install -y nodejs
# Install dependencies to temp directory
FROM base as build

# Dev dependencies 
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install

# Copy node_modules from temp directory to app directory
FROM base as prerelease
COPY --from=build /temp/dev/node_modules node_modules
COPY . .


# Copy the app to the final image
FROM base as release
COPY --from=build /temp/dev/node_modules node_modules
COPY --from=prerelease /app/src/app.ts src/app.ts
COPY --from=prerelease /app/package.json package.json

# USER bun
ENTRYPOINT [ "bun", "run", "dev" ]

Versions

  • @discordjs/opus 0.9.0
  • Node.js 18 -> 19 -> 20 (All of them result the same issue)
  • Bun v1.1.6
  • Typescript v5.4.2
  • Docker ([oven/bun:slim] - Debian GNU/Linux 11)

Issue priority

Medium (should be fixed soon)

@quangpao quangpao added bug Something isn't working need repro labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need repro
Projects
None yet
Development

No branches or pull requests

1 participant