gpt4 book ai didi

reactjs - Webpack/Babel/React 构建错误 : "Unknown option: foo/node_modules/react/react.js.Children"

转载 作者:行者123 更新时间:2023-12-03 12:54:25 25 4
gpt4 key购买 nike

我正在尝试使用 webpack 构建一个项目并与此 webpack 配置使用react:

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"
},
]
}
};

我确信我也有所需的 pm 模块并且安装了 webpack,但是当运行 webpack 时我得到:

Module build failed: ReferenceError: [BABEL] /Users/me/foo/app/main.js: Unknown option: foo/node_modules/react/react.js.Children

有什么想法吗?

最佳答案

抱歉,我忘记安装babel-preset-react :

$ npm install babel-preset-react --save-dev

关于reactjs - Webpack/Babel/React 构建错误 : "Unknown option: foo/node_modules/react/react.js.Children",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33739933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com