【发布时间】:2016-10-31 11:45:09
【问题描述】:
我在反应中得到了迷你应用程序并尝试使用 npm start - package.json - "scripts" 启动它:{ “开始”:“节点 server.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"]
}]
}
};
有什么想法吗?谢谢。
【问题讨论】:
-
你使用的是什么版本的 webpack?当我将
loader: 'babel'更改为loaders: ['babel']时,我遇到了类似的问题。
标签: node.js reactjs npm webpack