Module parse failed: Unexpected token

Module parse failed: Unexpected token (9:16)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

报这个错是因为webpack没有配置对应的loader.

如果你是开发环境,使用npm start启动报错的,请检查webpack.development.js(打包环境是webpack.config.js),查看是否有配置对应的loader.

由于我用的是type-script,所以我增加如下配置:

      {

        test: /\.tsx?$/,

        use: "ts-loader",

        exclude: /node_modules/,

      },

你可能感兴趣的:(web开发,typescript)