Using Paths w/ TypeScript

I'm trying to use TypeScripts Paths to make it easier and cleaner to import modules, although I always get: Cannot find package '@modules/mongodb' imported from C:\ExampleDirectory I've tried using node -r tsconfig-paths/register ., but that doesn't work and it still shows the same error above. The only thing that did manage to work was using tsx, but unfortunately that's not supported by Sapphire so no commands, listeners, or interaction handlers loaded.
Solution:
Turns out that compiling it then running it with tsx works perfectly fine ```json "main": "dist/index.js", "type": "module", "scripts": {...
Jump to solution
2 Replies
Turkinator
TurkinatorOP10mo ago
My explanation seems to be quite vague, so please ask any questions Ah actually I found a fix lol
Solution
Turkinator
Turkinator10mo ago
Turns out that compiling it then running it with tsx works perfectly fine
"main": "dist/index.js",
"type": "module",
"scripts": {
"compile": "tsc && tsx .",
"dev": "tsc-watch --onSuccess \"tsx .\""
},
"main": "dist/index.js",
"type": "module",
"scripts": {
"compile": "tsc && tsx .",
"dev": "tsc-watch --onSuccess \"tsx .\""
},
Want results from more Discord servers?
Add your server