Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

417
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda