btholt / complete-intro-to-react

A Complete Intro to React, as Given for Frontend Masters
https://frontendmasters.com/learn/react/
MIT License
1.06k stars 927 forks source link

ERROR when importing data.json #100

Closed Maamun closed 6 years ago

Maamun commented 6 years ago

Trying to follow along with the Loading JSON Data video but i kept getting this error :

ERROR in ./data.json
Module build failed: SyntaxError: Unexpected token, expected ;

at first i thought that it was an eslint issue but it seems that it happens on the build step, i tried adding a json-loader to webpack but i get the same error, this is a caption of the error i get in the terminal

screen shot 2018-03-18 at 20 38 11

Any suggestions?

Maamun commented 6 years ago

That was my fault, the problem is this regex: /\.jsx?/, like this i'm telling webpack to use babel-loader with any file extension starting with .jsor .jsx and .json match the test. To fix this i had to replace ? with $, so the solution is :

rules: [
         {
            test: /\.jsx$/,
            loader: 'babel-loader'
         }
      ]