[Solved] Cannot find module 'express' or any module

I’ve had a discord bot up and running for about a month now and all of a sudden it came up with an error of "Cannot find module ‘express’. I havent touched the code in nearly 2 weeks and it randomly broke. I have another bot with the exact same ‘package.json’ and it’s doing fine; hasnt crashed like this. When I move differnet modules above express it then changes and says “cannot find module ‘{whatever the name of the module I moved to the top is}’”

https://pennywise-bot.glitch.me Here is the live app link.

This happened to my bot yesterday. I’d recommend going into the terminal and running
enable-npm

then waiting for that to run a bit and running
enable-pnpm

I’m going to file a bug. I believe it has to do with an outage we had.

I have already attempted that and it didnt work… weird

Ah, well this is hacky but what I’d do is remix it and see if it works in a remix, than copy over the env info to the new remix and rename the old one something like pennywise-bot-1 and the new rename to pennywise-bot

i’ll give it a shot :smiley:

Update: that didn’t work - I’m still given the same error after remixing the project and moving the token over.

Can I see your package.json file?

Blockquote
{
“name”: “discordbot”,
“version”: “0.0.1”,
“main”: “bot.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”,
“start”: “node bot.js”
},
“dependencies”: {
“node-schedule”: “^1.3.2”,
“discord.js”: “11.5.1”,
“quick.db”: “7.0.0-b21”,
“better-sqlite-pool”: “^0.1.2”,
“parse-ms”: “^2.0.0”,
“sqlite3”: “^4.0.4”,
“enmap”: “^5.2.3”,
“express”: “^4.17.1”,
“moment”: “^2.24.0”,
“moment-duration-format”: “^2.2.2”,
“ms”: “^2.1.2”,
“node.js”: “0.0.0”,
“sqlite”: “^3.0.0”,
“ytdl-core”: “^1.0.6”,
“yt-search”: “^0.2.0”,
“node-opus”: “^0.3.2”
},
“engines”: {
“node”: “9.x”
}
}

Try removing any node modules from the dependencies list that you’re not using. Also, remove node.js, since that’s not needed

That solved it! For anyone with the same problem - I removed both “node-opus”: “^0.3.2” & “node.js”: “0.0.0” and it came back to life

Thank you for the help :smiley:

No problem, glad it works now!

Having this in your dependencies can cause installs to fail, that’s why it wasn’t working most likely. you don’t need to list node.js for npm/pnpm to read as a dependency