我在 react 中得到了迷你应用程序,并尝试使用 npm start - package.json - "scripts"启动它:{ “开始”:“Node 服务器.js”
在 Windows 中一切正常,但是当尝试在 Ubuntu 控制台上启动时会抛出错误
/var/www/react_pwa/node_modules/webpack/lib/RuleSet.js:143
throw new Error("options/query cannot be used with loaders");
我已经更新了 node.js 和 npm,所以我认为这可能是 webpack 配置问题。该文件现在看起来像这样
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'eval',
entry: [
'react-hot-loader/patch',
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: 'index.html'
})
],
module: {
loaders: [{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src'),
query: {
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"react-hot-loader/babel"
]
}
},
{
test: /\.css/,
loaders: ["style", "css"]
}]
}
};
有什么想法吗?谢谢。
最佳答案
将 loaders: ['babel']
更改为 loader: 'babel'
它应该可以工作。
我认为您不能对多个“加载器”使用查询,因为它不知道将哪个查询附加到哪个加载器。
关于node.js - npm 启动 webpack 问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40302468/