小编Thi*_*ary的帖子

Webpack:./src/index.tsx 中的错误未找到模块:错误:无法解析“...”中的“./App”

尝试使用 webpack-dev-server 为我的应用程序提供服务时出现以下错误:

ERROR in ./src/index.tsx
Module not found: Error: Can't resolve './App' in 
'C:\Users\user\Desktop\react-resources-boilerplate\src'
 @ ./src/index.tsx 15:28-44
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx
Run Code Online (Sandbox Code Playgroud)

这是我的 webpack 配置文件:

const HtmlWebPackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
  entry: path.resolve(__dirname, 'src', 'index.tsx'),
  module: {
    rules: [
      {
        test: /\.ts|\.tsx$/,
        loader: "ts-loader",
      },
    ]
  },

  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    })
  ]
};
Run Code Online (Sandbox Code Playgroud)

这是我的 tsconfig 文件:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "jsx": "react",
    "sourceMap": true,
    "outDir": "./dist",
    "rootDir": …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack tsx ts-loader

3
推荐指数
1
解决办法
4236
查看次数

标签 统计

reactjs ×1

ts-loader ×1

tsx ×1

webpack ×1