Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda