Browserify, Babel 6, Gulp - Unexpected token on spread operator

That syntax is an experimental proposed syntax for the future, it is not part of es2015 or react so you'll need to enable it.

npm install --save-dev babel-plugin-transform-object-rest-spread

and add

"plugins": ["transform-object-rest-spread"]

into .babelrc alongside your existing presets.

Alternatively:

npm install --save-dev babel-preset-stage-3

and use stage-3 in your presets to enable all stage-3 experimental functionality.


I had the same issue, installed stage-2 plugin and modified my package.json file, which looks like below

"babel": {
    "presets": [
      "es2015",
      "react",
      "stage-2"
    ]
  }