Vote count: 0
OS: Windows 10 Pro
NPM Version: 3.8.6
So, when I run npm start
, the app runs fine. But when I run npm run build
, I get the following error message:
λ npm run build
> learn-redux@1.0.0 build C:\Users\*****\Documents\Projects\learn-redux
> npm run clean && npm run build:webpack
> learn-redux@1.0.0 clean C:\Users\*****\Documents\Projects\learn-redux
> rimraf dist
> learn-redux@1.0.0 build:webpack C:\Users\*****\Documents\Projects\learn-redux
> set NODE_ENV=production && webpack --config webpack.config.prod.js
Hash: e7a3bc9c356b59e5b8fb
Version: webpack 1.14.0
Time: 30691ms
Asset Size Chunks Chunk Names
bundle.js 710 kB 0 [emitted] main
bundle.js.map 5.51 MB 0 [emitted] main
[0] multi main 28 bytes {0} [built]
+ 583 hidden modules
ERROR in ./client/reducers/comments.js
Module build failed: SyntaxError: C:/Users/*****/Documents/Projects/learn-redux/client/reducers/comments.js: Unexpected token (30:6)
28 | return {
29 | // Current state
> 30 | ...state
| ^
31 | };
My code is as follows:
function comments(state = {}, action) {
if (typeof action.postId !== 'undefined') {
return {
// Current state
...state
};
}
return state;
}
and my webpack config is as follows:
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'source-map',
entry: [
'./client/reduxstagram'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/static/'
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': "'production'"
}
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
],
module: {
loaders: [
// js
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'client')
},
// CSS
{
test: /\.styl$/,
include: path.join(__dirname, 'client'),
loader: 'style-loader!css-loader!stylus-loader'
}
]
}
};
How can I resolve this?
asked 30 secs ago
Module build failed: SyntaxError: Unexpected token (ES6)
Aucun commentaire:
Enregistrer un commentaire