尝试运行 webpack 时出现以下错误:
命令:webpack -d --watch
.babelrc:
{
"presets" : ["es2015", "react", "stage-2"],
"plugins" : ["transform-flow-comments"]
}
网络包配置:
var webpack = require('webpack');
var path = require('path');
var FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
var config = {
plugins: [
new FlowBabelWebpackPlugin(),
],
entry: ['./src/app'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
},
module : {
loaders : [
{
test: /\.css$/,
loader: 'style!css?modules',
include: /flexboxgrid/,
},
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src'),
},
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader"
}
]
}
};
module.exports = config;
ERROR in ./src/app.js
Module build failed: ReferenceError: [BABEL] /Users/ user/gocode/src/github.com/natdm/mobilebid/frontend_v2/src/app.js: Unknown option: /Users/user/gocode/src/github.com/natdm/mobilebid/frontend_v2/node_modules/react/react.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [['presetName', {option: value}]] }`
它告诉我我有无效的预设选项,但我没有,也从来没有过,突然间它就坏了。我必须更新/更改什么才能使其正常工作?
最佳答案
你的 .babelrc
文件似乎是正确的,只要确保你已经安装了
通过
使用它们之前的所有预设 npm install babel-preset-es2015 babel-preset-react babel-preset-stage-2 --save-dev
关于javascript - 编译 Babel/React 时出错(未知选项),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42396768/