Errors loading Commands and Listeners on bun run
When trying to run application via
bun run
, receive errors for each command and listener created.
Here the following error:
Here is an example of a file (very barebone):
Solution:Jump to solution
i see the issue now:
the documentation mentions to set your
"main"
in the package.json to the src/index.js, so in my head i assumed it needed to point to my src/index.ts
. but i guess based off the outDir in the tsConfig, have to point to dist/index.js
...8 Replies
What's your tsconfig? Also are you sure you're using bun and not Deno because the error has
node_modules/.deno
@Boomeravna , sorry i was also testing to see if it was a bun runetime compiler/runetime issue so tried it with Deno but they both gave the same error
decided to also give other configurations of the tsconfig.json, so tried this as well:
same error
That seems fine at a glance. Make sure to nuke your node_modules between Deno and Bun tries. And for bun you can compare with https://github.com/sapphiredev/node-bun-example which is a known working sample.
GitHub
GitHub - sapphiredev/node-bun-example: A bot starting point with bu...
A bot starting point with bun for dev and node for prod - sapphiredev/node-bun-example
Sure, I'll try taking a look at this and nuke my node modules. One thing I did notice before my power went out, the file that's loading in the files, there was a check to see if it the file was a ts file and if it's an ESMmodule export and that ESMmodule was false
So something related to esm module
In the @sapphire/pieces
Setting "type": "module" in the package.json ensures sapphire loads in ESM mode
hmm, so i did update my package.json to type:"module" now and i can see that
this.clientUsesESModules
now returns true, so it grabs the url and appends the searchParams. so it looks like this:
but i guess the return mjsImport(url)
returns back an empty object
i guess ill try to look more in the example one, but the example one seems a bit weird, cause you essentially serve the bun.ts who then imports the main.ts to run
is there a particular reason for that approachSolution
i see the issue now:
the documentation mentions to set your
"main"
in the package.json to the src/index.js, so in my head i assumed it needed to point to my src/index.ts
. but i guess based off the outDir in the tsConfig, have to point to dist/index.js
so now errors dont throw.
though it seems my slash commands or listeners aren't still registered. for the example above, i put in the event for
voiceStateUpdate
, and tested just joining a VC to see a console.log be fired, but didn't seem like anything got fired