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

node.js server crash when searching for any valid treehouse username


in this step in the Build aSimple Dynamic Site with Node.JS course, in the "Reading from FIles" section, when i attempt to run the app.js for the server on port 3000 with node.js in the workspace console —

node app.js

it runs o.k. initially, responding with what i gave it to put in the console —

treehouse:~/workspace$ node app.js                                                    
Server up & running at http://<workspace-url>/, Port 3000.

and when i run the index.html in port 3000 from the workspace, with no user name, initially it works. however, if i add a valid username, like 'chalkers,' 'faddah' or 'davemcfarland' — it prints out the templates with the 'error.html' template, not the valid 'profile.html' template, every time, and then it crashes the node.js server with this trace error, so i cannot get any further usernames —

treehouse:~/workspace$ node app.js                                                    
Server up & running at http://<workspace-url>/, Port 3000.                            
      throw er; // Unhandled 'error' event                                            
Error: write after end                                                                
    at ServerResponse.OutgoingMessage.write (_http_outgoing.js:413:15)                
    at Object.view (/home/treehouse/workspace/renderer.js:10:12)                      
    at Profile.<anonymous> (/home/treehouse/workspace/router.js:40:16)                
    at Profile.emit (events.js:107:17)                                                
    at IncomingMessage.<anonymous> (/home/treehouse/workspace/profile.js:38:36) 
    at IncomingMessage.emit (events.js:129:20)                                        
    at _stream_readable.js:908:16                                                     
    at process._tickCallback (node.js:355:11)

??? — i have no idea what is failing here. i have made sure my code matches what was done in the module by downloading the "finished" version of the module code and compairing it to what i wrote in the workspace. here is the current snapshot of my workspace —


any help would be appreciated..


— faddah

 portland, oregon, u.s.a.

1 Answer

Pedro Esteves
Pedro Esteves
13,125 Points


In the line 41 of your router.js file, you have response.view, it should be renderer.view. This is the reason you always get the invalid username even when you put a valid one in the url.