Issue with Node.js

i cant seem to find an answer to this anywhere but my bot used to work with “require” (that’s also what it says to use in the discord.js guide) and i made a tiny tweak in the code and now it requires me to update each instance of require to import and gives me a host of errors. what can/should i do to make this problem non-existent when making my next bot?
7 Replies
d.js toolkit
d.js toolkit2w 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! - Marked as resolved by OP
duck
duck2w ago
this isn't really discord.js related, but sounds like that 'tiny tweak' in your code included switching from cjs to esm (presumably by specifying "type": "module" in your package.json)
musty
mustyOP2w ago
so uhhh should i just remain consistent with “import from” in the future? sorry im a little new
duck
duck2w ago
that's entirely up to you you may want to consider looking up the difference between cjs and esm and how to switch
musty
mustyOP2w ago
one last question - if im just normally making a bot in vscode, following the guide, i should just use import from? (sorry if that sounds dumb) what’d work
duck
duck2w ago
that still depends on you again, you may want to consider looking up the difference between cjs and esm and how to switch
musty
mustyOP2w ago
okay, thanks

Did you find this page helpful?