I build a relay small webpack and typescript demo to play with. If i run webpack with the webpack.config.js i get this error:
ERROR in ./js/app.ts
Module not
Leaving this here for posterity, but I had this exact same issue and my problem was that my entry path was not relative but absolute. I changed entry from:
entry: 'entry.ts'
to
entry: './entry.ts'
Tried all the suggestions above and it still didn't work.
Ended up being the tiniest detail:
In webpack.js, instead of:
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
The ordering should be:
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
Don't know why this is necessary, and to be quite honest, I'm beyond caring at this point...
I'm using tsconfig instead of webpack which also compiles the submodule to a bundle (index.js).
The issue for me was that I had forgotten to compile the submodule (ie run tsc
to generate index.js) before referencing it from outside.
Webpack does not look for .ts
files by default. You can configure resolve.extensions to look for .ts
. Don't forget to add the default values as well, otherwise most modules will break because they rely on the fact that the .js
extension is automatically used.
resolve: {
extensions: ['.ts', '.js', '.json']
}