Discord bot error "Cannot find module 'discord.js' "

When i was starting my discord bot using node.js, it says "error: Cannot find module ‘discord.js’ "

heres my package.json:

{
“name”: “richiebot”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“keywords”: ,
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“8ball”: “^1.0.6”,
“body-parser”: “^1.19.0”,
“canvas”: “^2.7.0”,
“cool-images”: “^1.0.3”,
“discord-economy”: “^1.2.2”,
“discord-jokes”: “^3.0.0”,
“discord.js”: “^12.5.1”,
“djs-ticketsystem”: “^2.1.0”,
“dotenv”: “^8.2.0”,
“ejs”: “^3.1.6”,
“express”: “^4.17.1”,
“express-session”: “^1.17.1”,
“http”: “0.0.1-security”,
“morgan”: “^1.10.0”,
“passport”: “^0.4.1”,
“passport-discord”: “^0.1.4”,
“quick.db”: “^7.1.3”,
“sqlite3”: “^5.0.2”
}
}

Try to do this in the console, let me know what you get back.

npm i discord.js

Hi @tay_buz, welcome to the forum :slight_smile:

Can you try putting an engines section in your package.json, like this:

  "license" : "ISC",
  "engines": {
    "node": "14.x"
  },
  "dependencies" : ...

lol im so dumb, all i needed to do is change the port

hey, can you help me with this? it says forEach is undefined

Could you make a new topic?

I figure that nobody can see the code that is telling you this. It is probably not a collection but who knows?

BUT please set up a simple bot following an article/tutorial and when you’ve done exactly what it outlines and it still doesn’t work post a sample of the code and/or a link to your project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.