Reputation: 230
I got mini app in react and trying to start it with npm start - package.json - "scripts": { "start": "node server.js"
All works fine in windows but when trying to start this on Ubuntu console throws an error
/var/www/react_pwa/node_modules/webpack/lib/RuleSet.js:143
throw new Error("options/query cannot be used with loaders");
I've updated node.js and npm so I thik this might be webpack configuration issue. The file looks like this now
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"]
}]
}
};
Any ideas? Thanks.
Upvotes: 4
Views: 830
Reputation: 5345
Change loaders: ['babel']
to loader: 'babel'
and it should work.
I don't think you can use query with multiple "loaders" because it doesn't know what query to attach to which loader.
Upvotes: 3
Reputation: 15345
You are probably missing a dependency in your package.json
.
Have you installed react-hot-loader
, css-loader
, style-loader
, babel-loader
,babel-core
, babel-preset-es2015
,babel-preset-react
,babel-preset-stage-0
?
Try running this command to make sure:
npm install --save-dev react-hot-loader css-loader style-loader babel-loader babel-core babel-preset-es2015 babel-preset-react babel-preset-stage-0
Another thing you can do is ls node_modules
in your windows setup and make sure all dependencies are in your package.json
so you install them on npm install
.
Upvotes: 1