Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
218,695 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
218,695 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.