#discordjs/voice can't find encryption package with pnpm - discord.js

When I try to play audio with #discordjs/voice I just get an error:
ERROR file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/util/Secretbox.ts:51
throw new Error(
^
ERROR Error: Cannot play audio as no valid encryption package is installed. 20:03:27
- Install sodium, libsodium-wrappers, or tweetnacl.
- Use the generateDependencyReport() function for more information.
at Object.fallbackError (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/util/Secretbox.ts:51:8)
at Networking.encryptOpusPacket (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/networking/Networking.ts:585:23)
at Networking.createAudioPacket (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/networking/Networking.ts:568:47)
at Networking.prepareAudioPacket (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/networking/Networking.ts:490:31)
at VoiceConnection.prepareAudioPacket (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/VoiceConnection.ts:520:27)
at AudioPlayer._preparePacket (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/audio/AudioPlayer.ts:640:15)
at AudioPlayer._stepPrepare (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/audio/AudioPlayer.ts:604:10)
at prepareNextAudioFrame (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/DataStore.ts:146:13)
at audioCycleStep (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/DataStore.ts:127:2)
at Timeout._onTimeout (file:///C:/Users/[username]/Desktop/code/[project name]/node_modules/.pnpm/#discordjs+voice#0.13.0_#discordjs+opus#0.9.0/node_modules/#discordjs/voice/src/DataStore.ts:139:42)
Here's the output of generateDependencyReport():
-------------------------------------------------- 20:11:50
Core Dependencies
- #discordjs/voice: 0.13.0
- prism-media: not found
Opus Libraries
- #discordjs/opus: not found
- opusscript: not found
Encryption Libraries
- sodium-native: not found
- sodium: not found
- libsodium-wrappers: not found
- tweetnacl: not found
FFmpeg
- version: 2021-09-08-git-5e7e2e5031-full_build-www.gyan.dev
- libopus: yes
--------------------------------------------------
These are my dependencies:
"dependencies": {
"#discordjs/opus": "^0.9.0",
"#discordjs/voice": "^0.13.0",
"consola": "^2.15.3",
"discord.js": "^14.6.0",
"libsodium-wrappers": "^0.7.10",
"sodium-native": "^3.4.1",
"tweetnacl": "^1.0.3"
},
As you can see I've clearly installed an encryption package, but it's not being detected by #discordjs/voice.
I believe it's because I am using pnpm, as it's node_modules format is different compared to normal npm.
Does anyone know how to make #discordjs/voice detect it?

It is a bug with #discordjs/voice if it can't work with symlinked dependencies.
But you can use node-linker=hoisted to install a hoisted node_modules without using symlinks. Put this setting to a .npmrc file in the root of you project, remove node_modules and run pnpm install.

Related

TypeScript 4.9 error (can`t use satisfies)

Why after npm install -g typescript#latest (for lates version at 2022.12 - 4.9v) i can`t use satisfies?
Error ... ! (error: Newline or semicolon expected)
At the package.json
"devDependencies": {
"typescript": "^4.9.4"
}
enter image description here
enter image description here

How do I solve this reference error when opening a file?

I'm trying to make a discord bot that can read dates from a txt file on my device.
I've read the documentation and looked over similar posts, but I keep running into the same error. Just starting to learn python so please excuse any obvious mistakes/ strange formatting.
list = open("dates.txt","r")
list.seek(0)
var firstLine = file1.readline()
file1.close()
bot.sendMessage({
to: channelID,
message: firstLine
})
The error:
C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\bot.js:241
list = open("dates.txt","r")
^
ReferenceError: open is not defined
at DiscordClient.<anonymous> (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\bot.js:241:13)
at DiscordClient.emit (node:events:527:28)
at DiscordClient.handleWSMessage (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\discord.io\lib\index.js:1854:11)
at WebSocket.emit (node:events:527:28)
at Receiver.ontext (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\WebSocket.js:841:10)
at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:536:18
at Receiver.applyExtensions (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:371:5)
at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:508:14
at Receiver.flush (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:347:3)
at Receiver.finish (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:541:12)
PS C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp>
Might be useful to know
This bot is able to do other things like respond to commands
dates.txt exists in the same folder at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp
So it seems like I completely mashed up python and nodejs on accident.
Not quite sure what I was thinking but that was the issue.
Simple answer — don't mix nodejs and Python.
First of all you should avoid to redefine "list" as this is python keyword.
Second, the command is correct and the "open" keyword is built in in native python. So it should work.
This exact line works in my python environment (even when overwriting "list").
When you look at the end of the lines of the error message you can see the ".js" endings. This is hinting, that you somehow try to interpret python code with a javascript interpreter.
Maybe you should post some more information about your system and setup.
If you use a proper python3 interpreter your code should work.

events.js:288 Error: write EPIPE when executing tests with Jest

I have a problem when setting React Testing Library into a new project, which is a project that generates common UI components for several projects. In one of the projects it is correctly setup, but when I added React Testing Library and updated dependencies in this project, I am able to run a test but not all of them.
If I do yarn test this is the result:
Test Suites: 8 passed, 8 of 33 total
Tests: 84 passed, 84 total
Snapshots: 0 total
Time: 28 sevents.js:288
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at ChildProcess.target._send (internal/child_process.js:806:20)
at ChildProcess.target.send (internal/child_process.js:677:19)
at ChildProcessWorker.send (C:\Users\user\workspace\project\node_modules\jest-worker\build\workers\ChildProcessWorker.js:291:17)
at WorkerPool.send (C:\Users\user\workspace\project\node_modules\jest-worker\build\WorkerPool.js:32:34)
at Farm._process (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:129:10)
at Farm._enqueue (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:152:10)
at Farm._push (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:159:12)
at C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:90:14
at new Promise (<anonymous>)
at Farm.doWork (C:\Users\user\workspace\project\node_modules\jest-worker\build\Farm.js:56:12)
Emitted 'error' event on ChildProcess instance at:
at internal/child_process.js:810:39
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
errno: 'EPIPE',
code: 'EPIPE',
syscall: 'write'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried doing rm -rf node_modules and then cleaning cache, and didn't work.
Any help?
It turns out that by changing some libraries in package.json the error dissapears:
Before (KO):
"babel-jest": "^24.9.0",
"jest": "^26.0.1",
After (OK):
"babel-jest": "^26.0.1",
"jest": "^25.5.4",
By doing yarn cache clean solved my problem. If you met pipe error similar like image below. I believe it is related to memory leaks.
In my case was the version of node. I had the version 15 (from Latest Features) and changed it to the stable version 14.17.3 (from LTS).
To know which version you have use node -v in a terminal.

fbt internationalization: ERROR in ./src/example/Example.react.js Module not found: Error: Can't resolve 'fbt'

I try to use new internationalization library from facebook - fbt, I follow by steps in doc:
git clone git#github.com:facebookincubator/fbt.git;
cd fbt/demo-app;
yarn install; # pull in dependencies
yarn manifest; # generate fbt enum manifests and source manifests
yarn collect-fbts; # Collect all fbt phrases from source
yarn translate-fbts; # Generate the translation payloads
yarn build;
yarn start; # Checkout your locally running server at localhost:8081
And in next I got next error on yarn build step:
ERROR in ./src/example/Example.react.js
Module not found: Error: Can't resolve 'fbt' in '/home/test/projects/fbt/demo-app/src/example'
# ./src/example/Example.react.js 36:0-80 37:0-4 100:17-31 104:18-29 113:6-23 141:9-12 143:43-46 145:43-46 159:10-27 164:15-29 165:9-12 168:15-29 169:9-12 172:15-29 173:9-12 176:15-29 177:9-12 185:21-24 198:21-24 219:15-29 220:9-12 223:15-29 224:9-12 227:15-29 228:9-12 231:15-29 232:9-12 236:9-12 238:10-13 240:58-61 243:9-12 246:10-13 256:21-24 289:15-26 290:9-12 293:15-26 294:9-12 297:15-26 298:9-12 301:15-26 302:9-12 305:15-26 306:9-12 309:15-26 310:9-12 314:9-12 340:10-13 344:32-35 344:78-81 346:9-12 346:27-30 348:9-12 352:12-15 362:9-12
# ./src/root.js
My apologies! It looks like we were missing a step in our documentation! You'll need to run yarn in the top-level first (to build the runtime library):
git clone git#github.com:facebookincubator/fbt.git;
cd fbt;
yarn;
cd demo-app
yarn ...

Error trying to create sourcemap with grunt-contrib-uglify

I'm attempting to add sourcemaps for an AngularJS application derived from the ngBoilerplate template, which uses grunt to build and grunt-contrib-uglify to minify the JavaScript sources into one app.js file.
The problem is that grunt can't actually write the sourcemap to disk, with this cryptic error (used grunt --verbose, edited only slightly):
Running "uglify" task
Running "uglify:compile" (uglify) task
Verifying property uglify.compile exists in config...OK
Files: release/assets/MyApp-1.0.0.debug.js -> release/assets/MyApp-1.0.0.js
Options: banner="", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="min", expression=false, sourceMap
Minifying with UglifyJS...Reading release/assets/MyApp-1.0.0.debug.js...OK
OK
Writing release/assets/MyApp-1.0.0.js...OK
Writing release/assets/MyApp-1.0.0.js.map...ERROR
Warning: Unable to write "release/assets/MyApp-1.0.0.map" file (Error code: undefined). Use --force to continue.
Aborted due to warnings.
The critical section being:
Warning: Unable to write "release/assets/MyApp-1.0.0.map" file (Error code: undefined). Use --force to continue.
Now you may be tempted to say this is a duplicate of the question Grunt Uglify source map “unable to write” except that case was a simple gotcha where the asker was using a new configuration style with an older version of the package, resulting in the error Unable to write "true" file. Not so in my case. It's pretty clear that the file name it is attempting to write is correct (the JS file plus the ".map" extension) but that the system can't do it and gives a colossally unhelpful "Error code: undefined" back.
Versions from the packages.json file - and I cleaned out the node_modules folder and re-ran npm install to make sure this is what was in use:
"devDependencies": {
"grunt": "0.4.5",
"grunt-recess": "0.6.1",
"grunt-contrib-jshint": "0.10.0",
"grunt-contrib-concat": "0.4.0",
"grunt-contrib-watch": "0.6.1",
"grunt-contrib-uglify": "0.5.0",
"grunt-karma": "0.6.2",
"grunt-ngmin-with-comments": "0.0.3",
"grunt-html2js": "0.2.3",
"grunt-groundskeeper": "0.1.9",
"lodash": "2.4.1",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-connect": "^0.7.1"
}
Inside node_modules, the uglify-js version is 2.4.14.
My Gruntfile config isn't exactly boilerplate ngBoilerplate - I've modified it some so that I can get a .debug.js that is unminified and a .js that is minified. Here it is:
uglify: {
compile: {
options: {
sourceMap: true
},
files: {
'<%= minJs %>': '<%= debugJs %>'
}
}
}
I have also tried:
specifying the sourceMapName property
As a string
As a function that takes the jsName and appends '.map' to it
As a function that does not try to write in the release/assets subdirectory
Not using the grunt templates and specifying the filenames for minJs and debugJs explicitly.
Nothing has worked. Any ideas?
I'm getting the same error with a different setup. Everything goes fine if I disable sourcemaps. I spent a couple hours debugging the error and gave up.
Just switch to an older version of grunt-contrib-uglify such as ~0.4 until they sort out what is wrong.

Resources