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

402
Vistas
Bot running error in discord.js (Error: Cannot find module / code: 'MODULE_NOT_FOUND', requireStack: [])

I recently switched from discord.py to discord.js and i am having an error when i try to run the bot

I've watched a lot of tutorials and tried all the different ways I've found to import the library into VS Code but they all give some error

What I'm trying to do now is this:

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

require('dotenv').config()

var prefix = '?'
var newprefix = ''

    client.on('ready', () =>
    {
        console.log('Online')
    })

And im getting this error when i type "node main.js":

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Users\username\OneDrive\Desktop\Bots\JSBot\main.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)   
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []

I believe I have downloaded the library and other dependencies correctly, but even if I try other methods some different error always comes up.

What would I be doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The issue lies in that the file you're trying to run is not existent in the current directory. Ensure that your primary file is named main.js and that your terminals directory is set to the directory which includes main.js while running node main.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