Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Discord JavaScript Error Please verify that the package.json has a valid "main" entry

I'm making a discord bot from a tutorial on yt. I'm a beginner in JS programming.

const Discord = require('discord.js');

const client = new Discord.Client();

client.once('ready', () => {

console.log('Bot is online!');

});

client.login('My token');

and when i write in cmd "node ." i got this error

Error: Cannot find module 'C:\Users\48795\Desktop\DiscordBot\main.js'. Please verify that the package.json has a valid "main" entry

←[90m at tryPackage (internal/modules/cjs/loader.js:320:19)←[39m

←[90m at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)←[39m

←[90m at resolveMainPath (internal/modules/run_main.js:16:25)←[39m

←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:70:24)←[39m

←[90m at internal/main/run_main_module.js:17:47←[39m {

code: ←[32m'MODULE_NOT_FOUND'←[39m,

path: ←[32m'C:\Users\48795\Desktop\DiscordBot\package.json'←[39m,

requestPath: ←[32m'C:\Users\48795\Desktop\DiscordBot'←[39m

}

How do i fix this error?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

In your package.json, you need to put in the main field, the name of your script. In your case whatever you named your file.

about 4 years ago · Juan Pablo Isaza Report

0

The error tells me at least that your index/main file is different in your package.json than it really is. What is your main file called?

You should try renaming it to main.js OR just rename the main field in your package.json file.

about 4 years ago · Juan Pablo Isaza Report

0

In your package.json you need to make sure your "main" field points to your main.js file. Its probably looking for index.js.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!