Cannot run the Bot
PhiJoTo opened this issue · 33 comments
Whenever I try to start the Bot, the following error message appears:
`> discord-tts-bot@1.1.0 start /home/ubuntu/TTSBot/discord-tts-bot
node ./src/app.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '@discordjs/form-data'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/ubuntu/TTSBot/discord-tts-bot/node_modules/discord.js/src/rest/APIRequest.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-tts-bot@1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2020-06-07T17_40_59_743Z-debug.log
ubuntu@ubuntu:~/TTSBot/discord-tts-bot/config$ npm start
discord-tts-bot@1.1.0 start /home/ubuntu/TTSBot/discord-tts-bot
node ./src/app.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '@discordjs/form-data'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/ubuntu/TTSBot/discord-tts-bot/node_modules/discord.js/src/rest/APIRequest.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-tts-bot@1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2020-06-07T17_44_34_382Z-debug.log
`
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@6.14.4 3 info using node@v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle discord-tts-bot@1.1.0~prestart: discord-tts-bot@1.1.0 6 info lifecycle discord-tts-bot@1.1.0~start: discord-tts-bot@1.1.0 7 verbose lifecycle discord-tts-bot@1.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle discord-tts-bot@1.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/TTSBot/discord-tts-bot/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/> 9 verbose lifecycle discord-tts-bot@1.1.0~start: CWD: /home/ubuntu/TTSBot/discord-tts-bot 10 silly lifecycle discord-tts-bot@1.1.0~start: Args: [ '-c', 'node ./src/app.js' ] 11 silly lifecycle discord-tts-bot@1.1.0~start: Returned: code: 1 signal: null 12 info lifecycle discord-tts-bot@1.1.0~start: Failed to exec start script 13 verbose stack Error: discord-tts-bot@1.1.0 start:
node ./src/app.js13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid discord-tts-bot@1.1.0 15 verbose cwd /home/ubuntu/TTSBot/discord-tts-bot/config 16 verbose Linux 5.4.0-1011-raspi 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error discord-tts-bot@1.1.0 start:
node ./src/app.js`
22 error Exit status 1
23 error Failed at the discord-tts-bot@1.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
`
Hey there, this may sound like a dumb question but did you run npm install
or yarn install
before trying to start the bot?
I installed npm but I didn't install yarn, sorry.. I will try it, I'm kinda new to Linux..
It still isn't working..
0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@6.14.4 3 info using node@v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle discord-tts-bot@1.1.0~prestart: discord-tts-bot@1.1.0 6 info lifecycle discord-tts-bot@1.1.0~start: discord-tts-bot@1.1.0 7 verbose lifecycle discord-tts-bot@1.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle discord-tts-bot@1.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/TTSBot/discord-tts-bot/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/> 9 verbose lifecycle discord-tts-bot@1.1.0~start: CWD: /home/ubuntu/TTSBot/discord-tts-bot 10 silly lifecycle discord-tts-bot@1.1.0~start: Args: [ '-c', 'node ./src/app.js' ] 11 silly lifecycle discord-tts-bot@1.1.0~start: Returned: code: 1 signal: null 12 info lifecycle discord-tts-bot@1.1.0~start: Failed to exec start script 13 verbose stack Error: discord-tts-bot@1.1.0 start:
node ./src/app.js13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid discord-tts-bot@1.1.0 15 verbose cwd /home/ubuntu/TTSBot/discord-tts-bot 16 verbose Linux 5.4.0-1011-raspi 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error discord-tts-bot@1.1.0 start:
node ./src/app.js`
22 error Exit status 1
23 error Failed at the discord-tts-bot@1.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
`
Oh no, you may have misunderstood me, you don't need yarn
. What I meant is that you should run npm install
before npm start
in the same folder where the bot is located.
I did both now but without success...
Do you get any error messages after running npm install
?
nope.. it says "audited 41 packages in 1.928s
found 0 vulnerabilities"
I see, I tried installing the bot in my computer and I got the same error. It seems that discord.js changed the way to install the version 12 of their library, which the bot currently uses.
I could do the fix later today but if you feel in a bit of a rush, you can do the following:
- Open the
package.json
file and remove the line that says:"discord.js": "github:discordjs/discord.js",
. - In your terminal, in the same directory as the file
package.json
, run the following commands:
rm -rf node-modules/
npm install
npm install discord.js
Finally, it should work. But like I said, I will make this change later tonight, so that the rest aren't forced to go through this. Please do tell me if after doing this the bot is running fine so I can close this issue.
Thanks for your report!
On the last command I get following error:
`ubuntu@ubuntu:~/TTSBot/discord-tts-bot$ npm install discord.js
npm WARN notsup Unsupported engine for discord.js@12.2.0: wanted: {"node":">=12.0.0"} (current: {"node":"10.19.0","npm":"6.14.4"})
npm WARN notsup Not compatible with your version of node/npm: discord.js@12.2.0
- discord.js@12.2.0
updated 1 package and audited 41 packages in 2.858s
found 0 vulnerabilities
`
As of right now, discord.js only supports node version 12 or higher and your current node version is 10 so you need to update it.
I really don't want to bother you but even after installing version 14 it isn't working.
Error: Cannot find module '../config/settings.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/home/ubuntu/TTSBot/discord-tts-bot/src/app.js:4:51)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-tts-bot@1.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2020-06-07T18_42_03_583Z-debug.log
I really don't want to bother you but even after installing version 14 it isn't working.
Don't worry man you're not bothering me, you're rather helping me improve this bot, which I'm grateful for.
As for the error you just posted right now, that shows that it's working but that you haven't followed the installation notes.
I am really sorry.. I forget renaming the config file.. But the error is still the same..
If you're getting the same error as the one your previously mentioned then it means that the filename is still incorrect or that the file is in the wrong folder.
And you're still getting the module not found settings.json
error when doing npm start
?
I see, the error is not the same but it still related to the update that there was with discord.js. I'm gonna work on it tonight, in tue meantime I invite you to use the version of the bot that I'm hosting until I fix it so that you can use your own self-hosted version.
Thanks for your report and I'm sorry for all the inconveniences this may have caused you.
Okay, really thank you.. I am gonna wait till tonight..
Hey there, I updated the code to work with the newest stable version of discord.js. I tested it on my local machine and it works with node versions 12.0.0 and 14.4.0.
Moreover, the last error that you were getting was due because you were running a node version older than the 12.0.0. Maybe you needed to restart your ssh connection?
In any case, if you update your bot by redownloading the zip with the code or by running git pull origin master
, you should have the new changes. Make sure you remove again the node-modules
folder and re-run npm install
and npm run
with the proper node version.
I completely reinstalled everything and this is the error I'm still getting.
`
discord-tts-bot@1.2.0 start /home/ubuntu/discord-tts-bot
node ./src/app.js
/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:443
.flat(2)
^
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.addFields (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42)
at MessageEmbed.addField (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:250:17)
at Object. (/home/ubuntu/discord-tts-bot/src/common/langsEmbed.js:13:4)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-tts-bot@1.2.0 start: node ./src/app.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-tts-bot@1.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2020-06-07T23_55_53_767Z-debug.log
`
If it has to do with node, how do I switch versions?
That error is due to the outdated node version. If you run node -v
what do you get?
v10.19.0
I figured it out.. Again, thanks for helping :)
One last question: How can I run the Bot, so that he stays online when I close putty?
I solved this using forever.. The Bot is in my channel now but it isn't saying anything..
https://discord.gg/vSUKgWr - This is my discord server. The prefix is "!"..
I solved this using forever.. The Bot is in my channel now but it isn't saying anything..
https://discord.gg/vSUKgWr - This is my discord server. The prefix is "!"..
Check the console output of your bot, maybe there's a clue there as to what's going on. Some things you should look out for:
- Does the bot have permissions to talk on your voice channel?
- Do you have ffmpeg installed on the computer running the bot?
But again, it's hard for me to help you right now without any console messages.
`(3:31:15 PM) - [ERROR] - Error: Error: Cannot find module '/home/ubuntu/discord- tts-bot/node_modules/@discordjs/opus/prebuild/node-v83-napi-v3-linux-arm64-glibc -2.31/opus.node'
Require stack:
- /home/ubuntu/discord-tts-bot/node_modules/@discordjs/opus/lib/index.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/util/loader.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/Opus.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/index.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/index.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B asePlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B roadcastAudioPlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/VoiceBro adcast.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/ClientVo iceManager.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/Client.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/index.js
- /home/ubuntu/discord-tts-bot/src/app.js
Error: Cannot find module 'node-opus'
Require stack: - /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/util/loader.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/Opus.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/index.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/index.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B asePlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B roadcastAudioPlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/VoiceBro adcast.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/ClientVo iceManager.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/Client.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/index.js
- /home/ubuntu/discord-tts-bot/src/app.js
Error: Cannot find module 'opusscript'
Require stack: - /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/util/loader.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/Opus.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/index.js
- /home/ubuntu/discord-tts-bot/node_modules/prism-media/src/index.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B asePlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/player/B roadcastAudioPlayer.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/VoiceBro adcast.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/voice/ClientVo iceManager.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/client/Client.js
- /home/ubuntu/discord-tts-bot/node_modules/discord.js/src/index.js
- /home/ubuntu/discord-tts-bot/src/app.js
at Object.loader [as require] (/home/ubuntu/discord-tts-bot/node_modules/pri sm-media/src/util/loader.js:12:9)
at loadOpus (/home/ubuntu/discord-tts-bot/node_modules/prism-media/src/opus/ Opus.js:17:17)
at new OpusStream (/home/ubuntu/discord-tts-bot/node_modules/prism-media/src /opus/Opus.js:46:10)
at new Encoder (/home/ubuntu/discord-tts-bot/node_modules/prism-media/src/op us/Opus.js:135:5)
at AudioPlayer.playPCMStream (/home/ubuntu/discord-tts-bot/node_modules/disc ord.js/src/client/voice/player/BasePlayer.js:58:34)
at AudioPlayer.playUnknown (/home/ubuntu/discord-tts-bot/node_modules/discor d.js/src/client/voice/player/BasePlayer.js:53:17)
at VoiceConnection.play (/home/ubuntu/discord-tts-bot/node_modules/discord.j s/src/client/voice/util/PlayInterface.js:71:28)
at /home/ubuntu/discord-tts-bot/src/classes/TTSPlayer.js:80:45
at processTicksAndRejections (internal/process/task_queues.js:97:5)
`
Hmm this is kinda weird. I tested the changes on two different machines with multiple node versions (macOS and Ubuntu Server) and they both work. Your error is displaying that node-opus
cannot be found which is required to use voice channels for the bot. My bet would be that your machine may have had some issues compiling the opus bindings when doing npm install
?
Maybe your computer doesn't have a C compiler installed?
Try running sudo apt-get install build-essential
and then try removing node-modules
and re running npm install
.
Finally, it works. Thanks for the massive help, I wouldn't have figured it out by myself by any chance :)
I'm glad it works now for you, you've been an immense help to realize that there were some changes that needed to be implemented since the latest discord-js update which I was unaware of.
I'll go ahead and close this issue, if anything else comes up, feel free to open a new one and I'll do my best to assist you!