Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack "Cannot find module" for "module": "esnext"

I have a webpack project with this in my "main.ts" module:

import {Elm} from "./MainModule";

it fails with:

TS2307: Cannot find module './MainModule'.

but when I switch my "tsconfig.json" from "module": "esnext" to "module": "commonjs", it works.

However, I need "esnext" in order to have code splitting.

Thoughts?

like image 457
Daniel Birowsky Popeski Avatar asked Mar 04 '23 21:03

Daniel Birowsky Popeski


1 Answers

I had the same issue, adding "moduleResolution": "node", to tsconfig.json seems to have fixed it.

More info on it here: https://www.typescriptlang.org/docs/handbook/module-resolution.html

like image 113
m0tive Avatar answered Mar 17 '23 04:03

m0tive