#error: Cannot use import statement with CommonJS-only features

1 messages · Page 1 of 1 (latest)

worthy atlas
#

I am using discord.js with bun, all my files are .ts

my package.json has type set to "module"

I dont quite understand why im getting this error

#

I dont understand why its trying to make me use requires over imports

leaden hull
#

can you show your file, like do you have module.exports?

worthy atlas
#

yeah its just a basic slash command

leaden hull
#

yeah thats the issue

#

use export default

#

(module.exports is commonjs and import is esm... therefore)

leaden hull
#

read title

worthy atlas
brazen plover
#

Kinda dumb of me ngl

leaden hull
#

i wonder, is bun nice and shows you the commonjs features in "error" or does it just die on file

brazen plover
#

-# btw, may i suggest using a discord library built for bun/with bun in mind?

leaden hull
worthy atlas
leaden hull
#

probably could be slightly simpler wording tbh but i think its 99% of time people get this is from module.exports

#

btw let me know if/when it works or if you have any other issues ;)