React Not Compiling Spread/Rest Operator

Posted 10 months ago

If you’re facing the error “Module build failed: SyntaxError: Unexpected token” when trying to use the spread operator. Chance are you’re missing the Object rest spread transform which can be found here:


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


yarn add babel-plugin-transform-object-rest-spread

Then if you don’t already have a .babelrc file, create one with the following.

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