Cannot find module "@discordjs/rest"

Whenever I try run any script that calls the discord.js library, I receive the following error:
Cannot find module "@discordjs/rest" from "/Users/[username]/Projects/discord-service/node_modules/discord.js/src/client/BaseClient.js"
Cannot find module "@discordjs/rest" from "/Users/[username]/Projects/discord-service/node_modules/discord.js/src/client/BaseClient.js"
I've reinstalled discord.js, but to no avail. I'm using the Bun runtime, if that's useful information.
8 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
monbrey
monbrey16mo ago
Not sure we officially support bun. Is there a flag to also install dependencies that you need to set?
zevnda
zevnda16mo ago
I've ran a test instance of djs v14.11 in the past using the Bun runtime, had no issues and don't recall needing to do anything extra to get it working either. Haven't tried any later version of djs though
axindev
axindevOP16mo ago
I've tried it inside node v20.9.0 and I receive the same error, meaning it has nothing to do with the runtime.
monbrey
monbrey16mo ago
How exactly have you installed it? Nobody else is having this issue so it's unlikely to be the package You don't have a global install or something?
axindev
axindevOP16mo ago
It's installed locally to the project's node_modules folder I might init a fresh NPM project and copy my JS files over. That'll probably solve the problem.
monbrey
monbrey16mo ago
Yeah give that a try, definitely seems like something weird in that project
axindev
axindevOP16mo ago
update: it worked closing the thread now

Did you find this page helpful?