Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a Simple Dynamic Site with Node.js Handling Routes in Node.js User Route

SyntaxError when no code exists on that line.

I'm getting an error when I try to run node app.js in the browser.

"SyntaxError: Unexpected token }"

It points to line 19 of app.js, but the code doesn't even reach to line 18 of my file. My Code:

var router = require("./router.js"); //Problem: We need a simple way to look at a user's badge count and JavaScript points from a web browser //Solution: Use Node.js to perform the profile lookups and serve our templates via HTTP

//Create a web server var http = require('http'); http.createServer(function (request, response) { router.home(request, response); router.user(request, response); }, 1000); //response.end('Hello World\n'); }).listen(3000); console.log('Server running at http://<workspace-url>/');

//Function that handles the reading of files and merge in values //read from file and get a string // merge values in to string

Steven Parker
Steven Parker
231,248 Points

To display code property (including lines and spacing), use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

1 Answer

Steven Parker
Steven Parker
231,248 Points

Without code formatting, it's hard to tell what's code and what's comment, but assuming this is one of the code lines:

}).listen(3000);

That close brace (and the close parenthesis too) have no corresponding opens to balance them.

Neil McPartlin
Neil McPartlin
14,662 Points

Yep. Steven is correct. I have just been doing this video and you have accidentally left in a remnant from the setInterval test Andrew did earlier. If you delete...

}, 1000);

...that should help.