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 Creating a Basic Template Engine in Node.js Reading from Files

Ava Jones
Ava Jones
10,723 Points

I think i am doing everything right but i get a throw error

Server running at http://<workspace-url>                                                                                                                
events.js:183                                                                                                                                           
      throw er; // Unhandled 'error' event                                                                                                              
      ^                                                                                                                                                 


 at Object.home (/home/treehouse/workspace/router.js:11:14)                                                                                          
    at Server.<anonymous> (/home/treehouse/workspace/app.js:9:10)                                                                                       
    at emitTwo (events.js:126:13)                                                                                                                       
    at Server.emit (events.js:214:7)                                                                                                                    
    at parserOnIncoming (_http_server.js:660:12)                                                                                                        
    at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)

My code: https://w.trhou.se/b5a035t0t7

Rich Donnellan
Rich Donnellan
Treehouse Moderator 27,708 Points

Question updated with code formatting. Check out the Markdown Cheatsheet below the Add an Answer submission for syntax examples, or choose Edit Question from the three dots next to Add Comment to see how I improved the readability.

1 Answer

Steven Parker
Steven Parker
231,275 Points

I noticed that the view method in renderer.js calls both the write method and the end method, which means that when it is used a 2nd time, it will cause a "write after end" error.

The code for the view method as shown in the video does not include the call to end.

Ava Jones
Ava Jones
10,723 Points

Thank you so much! I never would have realized my error.