Error: Cannot find module '@discordjs'

Ok so, I’m trying to activite my bot in discord, I have already coded some commands, and have it on my server. However, when I try to running it, it doesn’t work. Is my first bot and i don’t know what am I doing wrong.

Anyway, this is the error:
Error: Cannot find module ‘@discordjs
Require stack:

  • C:\Users\Windows 10\Desktop\Bot Discord\mazipedia.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (C:\Users\Windows 10\Desktop\Bot Discord\mazipedia.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
    code: ‘MODULE_NOT_FOUND’,
    requireStack: [ ‘C:\Users\Windows 10\Desktop\Bot Discord\mazipedia.js’ ]

And this is my package.json:
{

“name”: “bot-discord”,

“version”: “0.5.0”,

“description”: “”,

“main”: “mazipedia.js”,

“scripts”: {

"test": "echo \"Error: no test specified\" && exit 1"

},

“author”: “Mazizorro”,

“license”: “ISC”,

“dependencies”: {

"discord.js": "^12.3.1"

}

}

If you could help me, I would be very thankful

P.S: English isn’t my first language, and this is my first project ever.

Thank you very much

npm i discordjs

You could also try using this

npm install discordjs

also try to use backticks next time!

npm install is an alias for npm i so you kind of made a duplicate. Also you might wanna add --save to the end of it to update your package.json file (or just run npm init -y && refresh)

3 Likes

True, and --save is good to add to not get worried about your packages.

Could you change

"discord.js":  "^12.3.1"

to

"discordjs": "^12.3.1"

because the oackage name doesn’t have a “.” in it. Also, can you try getting rid of the @ when you require the package in your js file? Hopefully this will work.
But also make sure you have discordjs installed, as the others said.
Happy Glitching!

I tried what you said, but still dont work, also, i have revised my node_modules folder, and i have @discordjs and discord.js, should i uninstall both and reinstall? If not, do you think if i rewrite the entire bot, or simply write a new one, will fix the problem?

Ok, im stupid, the mistake was in my main, mazipedia.js , basically, instead of write “discord.js” i wrote “@discordjs”. IDK if a mistake itself, but fixed the bot, thanks everyone for help me.

4 Likes