2

My node application does not run when i run node index.js

File index.js:

const Discord = require('discord.js');
const bot = new Discord.Client();

const token = '<my-token>';
bot.on('ready', () =>{
    console.log('This bot is online!');
})


bot.login(token);

This is the stacktrace of the error:

Error: Cannot find module 'C:\Users\Thela\Desktop\Discord UWU\run'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11 {
4
  • Did you ran npm i discord.js? Commented Nov 4, 2019 at 21:02
  • Yes I Did @mthrsj Commented Nov 4, 2019 at 21:04
  • What exactly are you asking? Add your exact question by editing your post. Commented Nov 4, 2019 at 21:25
  • @CodePortal I'm trying to reproduce your error and I couldn't. The token that I've removed from your question isn't in the right format. Go to the "Bot" tab in Discord application dashboard an get the token below the bot name Commented Nov 4, 2019 at 21:33

1 Answer 1

2

It looks like you are starting the bot incorrectly. Make sure to do node <path to bot main file>

e.g.

node "C:\Users\ExampleUser\Documents\ExampleBot\app.js", with app.js being the file you posted. Make sure to switch this all out with your own files/paths

To make it easier, you can also cd to the corresponding folder and run node app.js from there.

Sign up to request clarification or add additional context in comments.

2 Comments

To make it easier, you can also cd to the corresponding folder and run node app.js from there.
@TheNewGuy added that to my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.