Comments (6)
Since it seems several other people are having this issue as well, would it be possible to add a workaround for now and then perhaps look at other options later (I assume those would take longer than adding a few config lines)?
from voice.
I found a rather elegant solution to avoid modifying all your code to CJS.
This way NodeJS will load the CJS version of @discordjs/voice
instead of ESM.
import { createRequire } from "module";
const {
joinVoiceChannel,
createAudioPlayer,
createAudioResource,
entersState,
VoiceConnectionStatus,
NoSubscriberBehavior,
} = createRequire(import.meta.url)("@discordjs/voice");
from voice.
This is related to this issue with esbuild evanw/esbuild#946
Affected files are:
https://github.com/discordjs/voice/blob/main/src/util/generateDependencyReport.ts
https://github.com/discordjs/voice/blob/main/src/util/Secretbox.ts
These files use require
which is not defined in es module scope. But esbuild should have created the require
function in this case.
There is a workaround described in the esbuild issue but maybe we should consider migrating to dynamic import syntax or reading and parsing json files manually
from voice.
Same here on Linux (Debian 10 Buster).
from voice.
Is this a workaround in your build or a workaround we're expected to run in our environment?
from voice.
Let me reopen this issue to notify of a strange behavior that may occur when using createRequire
.
https://nodejs.org/api/packages.html#dual-package-hazard
Just to be sure, this should remain a temporary solution until the problem is fixed on esbuild.
Otherwise we should find another solution to load the dependencies.
from voice.
Related Issues (20)
- trying to establish a connection always fail for timeout while waiting status to be ready HOT 4
- Optional Client parameter for joinVoiceChannel() HOT 2
- CVE-2021-3807: Inefficient Regular Expression Complexity in chalk/ansi-regex HOT 5
- Record Audio (Simple Example) HOT 1
- Unable to create oggStream HOT 2
- Player Idle for custom ffmpeg stream
- entersState seems to be locking the thread for itself, causing abortions to always happen HOT 2
- DiscordJS/Voice AudioPlayer goes on Idle while playing livestreams on ytdl after a few seconds HOT 4
- Bot does not connect to voice channel HOT 1
- Discord bot issue HOT 1
- Old documentation HOT 1
- High ram usage HOT 1
- music bot sound lags
- You can't use Multiple clients at once HOT 6
- Bots using CommonJS requiring the package are broken HOT 2
- High latency buffering of audio before playback HOT 1
- Discord voice does not work with local files HOT 1
- discordjs/voice TypeScript's definition "import" causes a TypeScript compilation error HOT 1
- Allow the option to record raw PCM data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voice.