首页 > 解决方案 > React - 错误:找不到所需的文件;在 ../../public 中搜索

问题描述

我正在制作一个 MERN 应用程序,运行后出现上述错误npm start。我删除了index.htmland public folder,然后将其替换为client/index.ejs. 我的webpack.config.js文件如下所示:

//webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
 entry: './client/index.js',
 output: {
  path: path.join(__dirname, 'client'),
  filename: 'bundle.js'
 },
 module: {
  loaders: [{
   test: /.jsx?$/,
   loader: 'babel-loader',
   exclude: /node_modules/,
   query: {
    presets: ['es2015', 'react']
   }
  },
  {
   test: /\.css$/,
   loader: "style-loader!css-loader"
  }]
 }
}

另外,这是我在 StackOverflow 上的第一篇文章。呜呼!

标签: reactjswebpackmern

解决方案


推荐阅读