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

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

hi,

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.                            
events.js:85                                                                          
      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 —

https://w.trhou.se/uk66fuln6s

any help would be appreciated..

best,

— faddah

 portland, oregon, u.s.a.

1 Answer

Pedro Esteves
Pedro Esteves
13,125 Points

Hi,

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.