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

412
Views
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 answers
Answer question

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 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!