Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Can';t解析'/src&x27;网页包更新后-如何调整以前的工作配置?_Reactjs_Webpack - Fatal编程技术网

Reactjs Can';t解析'/src&x27;网页包更新后-如何调整以前的工作配置?

Reactjs Can';t解析'/src&x27;网页包更新后-如何调整以前的工作配置?,reactjs,webpack,Reactjs,Webpack,我正在努力将webpack从版本2.7.0更新到版本4.40.2。以下是错误: webpack is watching the files… Insufficient number of arguments or no entry found. Alternatively, run 'webpack(-cli) --help' for usage info. Version: webpack 4.40.2 Time: 42ms Built at: 2019-09-16 12:34:56 WARN

我正在努力将webpack从版本2.7.0更新到版本4.40.2。以下是错误:

webpack is watching the files…
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Version: webpack 4.40.2
Time: 42ms
Built at: 2019-09-16 12:34:56
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in Entry module not found: Error: Can't resolve './src' in 'C:\myUIproject\'
Process terminated with code 0.
保留关于丢失的
--mode=development
asside的警告,我以前使用的
Webpack.config.js
(见下文)不再工作:
无法解析。/src'

上面已经有一篇Stackoverflow文章,给出的解决方案是完全删除webpack配置文件,但使用如下方式:

webpack ./src/index.tsx --output ./dist/bundle.js --mode development
我将其调整到我的架构(我希望如此),但我得到了以下错误,这意味着我没有:

Version: webpack 4.40.2
Time: 42ms
Built at: 2019-09-16 12:34:56
    Asset      Size  Chunks             Chunk Names
bundle.js  4.13 KiB    main  [emitted]  main
Entrypoint main = bundle.js
[./src/index.tsx] 350 bytes {main} [built] [failed] [1 error]

ERROR in ./src/index.tsx 51:4
Module parse failed: Unexpected token (51:4)
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
|
| ReactDOM.render(
>     <LocaleProvider locale={enUS}>
|         <Provider store={store}>
|             <Layout>

您是否尝试将此更新为
模块.rules
而不是
模块.loaders

例如:

module.exports = {
  module: {
    rules: [
      { test: /\.css$/, use: 'css-loader' },
      { test: /\.ts$/, use: 'ts-loader' }
    ]
  }
};


谢谢你抽出时间。我必须承认,我对
webpack
了解不多,所以如果您能解释一下您的想法,我将不胜感激。我真正想要的是最简单的解决方案,我发现在我的
package.json
中只有两个webpack命令行的想法非常吸引人。
module.exports = {
  module: {
    rules: [
      { test: /\.css$/, use: 'css-loader' },
      { test: /\.ts$/, use: 'ts-loader' }
    ]
  }
};
    module: {
        rules: [
            // All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
            { test: /\.tsx?$/, use: [
            {
                loader: 'babel-loader',
                options: {
                    presets: [[
                        'env',
                        {
                            "targets": {
                                "browsers": ["ie >= 11"]
                            }
                        }
                    ]]
                }
            },"ts-loader"] },
            { test: /\.js$/, loader: "source-map-loader" },
            { test: /\.less$/, loader: ExtractTextPlugin.extract("css-loader!less-loader") }
        ]
    }