- What's your exact discord.js
npm list discord.jsand nodenode -vversion? - Not a discord.js issue? Check out #1081585952654360687.
- 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!
#Want to deploy my bot but its not working?!
61 messages ยท Page 1 of 1 (latest)
You can't import a folder. That is indeed wrong in your code
Show your imports in index.ts
ah
import { commands } from "./commands";
import { deployGlobalCommands } from "./deploy-commands";
import { EnhancedLogger } from "./logger/enhancedLogger";
import { TicketHandler } from "./handlers/ticketHandler";
import { ApplicationHandler } from "./handlers/applicationHandler";
import { SuggestionHandler } from "./handlers/suggestionHandler";
import { GiveawayHandler } from "./handlers/giveawayHandler";
import { startRoleAssigning } from "./Listeners/JoinRole";```
What runtime do you use to run that? Considering you say node but it seems to run ts files
You probably want from "./commands/index.js"
its typescript
That's the language. But how do you run it? node with experimental CLI flags or another runtime or..?
thats what you run to start it on your local pc but since it works there but not on the host im assuming the host just tries to run it with normal node which doesnt support running typescript directly
my hosts startup command is
if [[ -d .git ]] && [[ 1 == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; if [[ "${MAIN_FILE}" == "*.js" ]]; then /usr/local/bin/node "/home/container/${MAIN_FILE}" ${NODE_ARGS}; else /usr/local/bin/ts-node --esm "/home/container/${MAIN_FILE}" ${NODE_ARGS}; fi```
Why? Why do you run dev mode / watch on your host?
Ah, so it's not actually running your dev script but instead ts-node... that's a bad idea
I'd rather suggest uploading the transpiled js files and run those on your host
Are you also new to typescript as a language?
tsc or any other transpiler you use will give you .js files
yea first time
Then where did you get all that content you have from? Who told you to use tsx and all that stuff?
Then ask that friend how to run in production
Because that's definitely not gonna get you the answer npm run dev
he doesnt know as he dont make discord bots ๐
Irrelevant. If he does anything in typescript then that anything would still run in production in the end
Alternatively don't use tsx and instead tsc
bet
Assuming you have a tsconfig setup
No
Just add another script in your package.json, name it build for example and just put tsc.
Maybe want to add an outdir: config in your tsconfig.json before
In scripts you don't needs the npx
Because that's when you run from console directly. In npm scripts the npx always is implied
Try it and see
nothing happens
yea
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/container/src/config/config' imported from /home/container/src/index.ts
at finalizeResolution (node:internal/modules/esm/resolve:275:11)
at moduleResolve (node:internal/modules/esm/resolve:860:10)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (/usr/local/lib/node_modules/ts-node/dist/child/child-loader.js:15:125)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
at handleMessage (node:internal/modules/esm/worker:199:24)
at Immediate.checkForMessages (node:internal/modules/esm/worker:141:28)
at process.processImmediate (node:internal/timers:505:21) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///home/container/src/config/config'
}
Even there is a src/config/config.ts
BRO!