Webpack cant resolve TypeScript modules

前端 未结 4 1432
耶瑟儿~
耶瑟儿~ 2020-12-14 05:43

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         


        
4条回答
  •  情歌与酒
    2020-12-14 06:24

    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']
    }
    

提交回复
热议问题