Webpack cant resolve TypeScript modules
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']}
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...
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'