Build Error with ts-node

Hi, I'm using typescript and I'm getting a strange error that isn't actually in my file!
Error:
        Failed to import from:
            /Users/marlon/Javascript/communaute-events/ce-discord-bot/src/commands/alerts/alerts.ts.
        Options:
            {}
        Require error message:
            TSError: ⨯ Unable to compile TypeScript:
src/commands/alerts/functions.ts:2:32 - error TS2532: Object is possibly 'undefined'.

2 var __importDefault = (this && this.__importDefault) || function (mod) {
                                 ~~~~

    at createTSError (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1433:41)
    at Object.m._compile (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1617:30)
    at Object.m._compile (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
    at require.extensions.<computed> (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1621:12)
    at Object.require.extensions.<computed> [as .ts] (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/ts-node/src/index.ts:1621:12)
    at /Users/marlon/Javascript/ce-discord-bot/node_modules/esm/esm.js:1:251778

    at esmImport (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/import-sync/src/import.ts:48:11)
    at importSync (/Users/marlon/Javascript/communaute-events/ce-discord-bot/node_modules/import-sync/src/import.ts:70:26)
    at scanDirectory (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/core/deploy-commands.ts:38:46)
    at scanDirectory (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/core/deploy-commands.ts:34:17)
    at scanCommands (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/core/deploy-commands.ts:55:5)
    at getCommandObjects (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/core/deploy-commands.ts:61:26)
    at deployCommands (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/core/deploy-commands.ts:87:22)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Client.<anonymous> (/Users/marlon/Javascript/communaute-events/ce-discord-bot/src/index.ts:36:5)


The code in question:
https://srcb.in/HRuwOaDSwE

To load this file, i'm using the "import-sync" module.
const module = importSync(filePath)
SourceBin
Instantly share your code with the world.
Was this page helpful?