KRuslK
Deno3y ago
4 replies
KRusl

Error with imports

I have this fancy peace of code that import a bunch of files from a directory:
const utils = {};
const utilsDirectory = Deno.realPathSync(`${Deno.cwd()}/utils`);
const utilsFiles = Deno.readDirSync(utilsDirectory);

for (const utilsFile of utilsFiles) {
    const filePath = `${utilsDirectory}/${utilsFile.name}`;
    import(pathToUrl(filePath)).then(util => {
        Object.assign(utils, util);
    });
}

Structure of utils directory is:
- utils
    - getTime.ts
    - pathToUrl.ts
    - someOtherFuncs.ts

When run this code using deno run everything is alright. But when I'm trying to deploy my app to Deno Deploy via deployctl deploy I receive this error:
× Deployment failed.
error: The deployment failed: UNCAUGHT_EXCEPTION

Uncaught (in promise) TypeError: module not found: 'file:///utils/getTime.ts'

Is there are something tricky about Deno Deploy FS? I don't get it why deno can't find this file.
Was this page helpful?