[英]Webpack error when i install react.(when i try to use “npm start” to start a sever)
it's the log of the error. 这是错误的日志。
when i try to start a sever by use "npm start",it give me this. 当我尝试使用“ npm start”启动服务器时,请给我这个。 My configuration is below .
我的配置如下。
var config = {
entry: './main.js',
output: {
path: '/C:\Users\34337\reactApp',
filename: 'index.js',
},
devServer: {
inline: true,
port: 7777
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}]
}
};
module.exports = config;
after i replace "loders" to "rules",it shows that i didn't set 'mode' option. 在将“ loders”替换为“ rules”之后,它表明我没有设置“ mode”选项。 the error after that.
之后的错误。
You need to check of babel-cli
and babel-loader
installed in your env, if not installed, run command: npm install --save babel-cli babel-loader babel-preset-es2015 babel-preset-react
then rerun your starting script. 您需要检查环境中安装的
babel-cli
和babel-loader
,如果未安装,请运行命令: npm install --save babel-cli babel-loader babel-preset-es2015 babel-preset-react
然后重新运行启动脚本。
And configuration module
point should looks like this: 并且配置
module
点应如下所示:
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}
]
}
For now you can ignore mode
warning. 目前,您可以忽略
mode
警告。 Pay attention of my module
config, and set babel-loader
instead of babel
. 注意我的
module
配置,并设置babel-loader
而不是babel
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.