#Module build failed, Syntax Error Unexpected token

5 messages · Page 1 of 1 (latest)

gray beacon
#

@peak remnant So this webpack version which bundles the files to generate the project on scrimba.com is a little different than what you usually would run when working on a react project locally.

Because of that this webpack configuration doesn't support the spread or rest operator out of the box and you will need to install a plugin for webpack to enable that. And then once that is installed you can enable the plugin in the webpack config file.

Step 1: cd in to your project and install
npm i babel-plugin-transform-object-rest-spread

Step2: After installation, open your webpack.config.js and below the presets add the plugin like this.

"presets": [
"babel-preset-env",
"babel-preset-react"
],
"plugins": ["babel-plugin-transform-object-rest-spread"]

After that you can use npm run build command to build the index.html.

Although this being so messy and just a band aid solution I would recommend to not use this to deploy, in future you will learn a better way to run and build your React projects.

peak remnant
peak remnant
gray beacon
#

@peak remnant look in your package.json file, I believe the command is "npm run watch"