Ravenous Part 1 - Failed to compile

Has anyone got a similar error message? I don’t understand what the problem is with Line 9.


Failed to compile.

./src/App/App.js
Line 9: Parsing error: Unexpected token

7 | class App extends React.Component {
8 | return (
9 | <div className=“App”>
10 | <h1>ravenous </h1>
11 | <SearchBar />
12 | <BusinessList />

Could not open App.js in the editor.
The editor process exited with an error: spawn atom ENOENT.

To set up the editor integration, add something like REACT_EDITOR=atom to the .env.local file in your project folder and restart the development server. Learn more: https://goo.gl/MMTaZt

The parser has no idea what’s wrong.
It can’t tell you that line 9 is the problem.
But it can tell you that from what it has read so far, line 9 doesn’t make sense.

So when would something be unexpected? When something else is expected. When would something be expected? If you started something that needs finishing. It’s up to you to close your parentheses and so on.

Thanks for your response but there is actually a closing div tag in my code at Line 13 which doesn’t show in error message above so it shouldn’t be the issue. The closing parenthese for the return statement and a curly one for the App component are there too; they just don’t show in error message that I copied and pasted from terminal.

Didn’t say it was a div tag.
Closing whatever it is at line 13 wouldn’t help, since things already don’t make sense by line 9. You’d need to look upwards. Not downwards.

a.js:

)

$ node a.js
a.js:1
)
^

SyntaxError: Unexpected token )

For this file, you would need an opening brace, otherwise the parser encounters a closing brace even though one wasn’t opened, making it unexpected. There’s nothing too exotic about this kind of error. Make sure everything matches up, that is all.

If you have more code in that general area than you can handle, then try commenting some out and then add it back in only in matching increments.

Sorry, I’m not sure if I understand your point. You say things already don’t make sense by line 9. Can you please clarify what things? I already checked a few times and everything matches up in the code; it is exactly the same as provided in the project walkthrough video.

Hi Did you find the solution?
I am having similar issues… I have read that it could be something to do with how babelrc is installed(?) by React but the technicality of it goes beyond my current comprehension…

Unfortunately no, I even contacted one of the moderators but couldn’t find a solution so gave up and moved on. Please let me know if you find out anything.

1 Like

Hi,

So I totally deleted the project and started again with fresh eyes.
I believe I have found the issue at Step 47. Can you check your App.js file and copy it here. If the file is using -

function App() {....}

Which is the way create-react-app seems to have installed it for me, then you may need to change the syntax to -

class App extends React.Component {.....};

Hope this helps!

1 Like

Hi, I got fed up and moved on with the project so cannot really tell now what the problem was (think I will need to do what you did and start again with fresh eyes) but thanks for your message, others who face the same issue can find this post and refer to your suggestion here. Cheers!