#Compiling problems

6 messages · Page 1 of 1 (latest)

drifting bridge
#

hi, I'm working on my discord bot with typescript and I want to import my files
( example : )

import credentials from "./configs/credentials.json" assert { type: "json" };
import { LoadSlashCommand } from "./loaders/loadSlashCommands";
import { Client, IntentsBitField, ThreadChannel, VoiceState } from "discord.js";
import fs from "fs";
import { Parties } from "./misc/Parties";

I have this error :

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'path\dist\src\loaders\loadSlashCommands' imported from path\dist\src\main.js

so the dist folder is the compiled js version of my ts files, imports with no '.js' extension don't work, how can I make it so I don't have to put '.js' at the end of my imports.
ask me if it's not clear enough

dreamy harbor
#

Why did you compile your src directory into a dist/src directory? It‘s not source anymore

drifting bridge
#

didnt think about that lol

dreamy harbor
drifting bridge
#

but my ts server won't recognize the files...?

dreamy harbor
#

It should. TS is intelligent enough to turn the js into ts for its checks (or to be more precise to know what file will become that .js you import there)