Application deployed to Netlify unable to find files without .js extension

20 Views Asked by At

I am building an app with HTML, CSS (Tailwind), and TypeScript. I deploy the app on Netlify.

In my .ts files, I import modules like so: import { validateImage } from "../utils/validateImage"; In my development environment, this works well. But as soon as the application is deployed to Netlify, I get errors from the server not finding the files in question. If I add the .js file extension, everything works: import { validateImage } from "../utils/validateImage.js";

tsconfig.json:

{ "compilerOptions": {
    "target": "es6",
    "module": "ES6",
    "outDir": "./public/js",
    "rootDir": "./src",

    "strict": true,

    "moduleResolution": "node",
    "esModuleInterop": true,
    "sourceRoot": "../src",
    "inlineSourceMap": true,

    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "exclude": ["**/*.test.ts", "**/*.spec.ts", "tests/"]
}

Does anyone know why this is?

I have tried different configurations in the tsconfig file, although I would expect any issues on this end to also be so in dev. So I suspect this has something to do with Netlify, but I can't find any information that helps me. Also posted it in the Netlify forum, but still no reply.

0

There are 0 best solutions below