解决问题(Module build failed ReferenceError [BABEL] main.js Unknown option react.js.Children)
使用webpack和babel构建项目时报错,报错信息如下:
Module build failed: ReferenceError: [BABEL] /Users/me/foo/app/main.js: Unknown option: foo/node_modules/react/react.js.Children
Webpack配置如下:
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: [
'babel-polyfill',
'./app/less/main.less',
'./app/main.js',
'webpack-dev-server/client?http://localhost:8080'
],
output: {
publicPath: '/',
filename: 'dist/main.js'
},
debug: true,
devtool: 'source-map',
module: {
loaders: [
{
test: /\.js$/,
include: path.join(__dirname, 'app'),loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.less$/,
loader: "style!css!autoprefixer!less"
},
]
}
};
【解决问题(Module build failed ReferenceError [BABEL] main.js Unknown option react.js.Children)】解决办法很简单,只需使用npm安装
babel-preset-react
即可,如下:npm install babel-preset-react --save-dev
推荐阅读
- 精品资源!BAT大牛亲授 基于ElasticSearch的搜房网实战百度网盘下载
- Windows Office专业版2016双击激活工具下载和完全安装教程
- 如何实现优先队列(Java使用数组实现最小堆和优先队列)
- wordpress个人博客主题BuddyPress最新中文版在线社区系统社交网站免费下载
- 解决问题(Failed to load resource the server responded with a status of 404 (Not Found))
- 解决Vue错误([Vue warn] Error in render RangeError Invalid array length)
- 解决Vue问题([Vue warn] Avoid mutating a prop…Prop being mutated list (found in component ))
- 解决Vue问题(Uncaught ReferenceError Vue is not defined)
- 解决vue-cli安装错误(npm ERR! A complete log of this run can be found in npm ERR!)