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 Node.js Basics (2014) Building a Command Line Application Handling Errors in Node

The Node.js console is not responsive to anything that I input from the app.js file.

for example this is my code below and I should get an error in the Node.js console but I am not.

var request = http.get(teamtreehouse.com/" + username + ".json", function(response){ console.dir(response.statusCode); //Read the data //Parse the data //Print the data

}); request.on("error", function(error){ console.error(error.message);


I just get this in the Node.js console.

at exports.runInThisContext (vm.js:53:16)                                                    
at Module._compile (module.js:373:25)                                                        
at Object.Module._extensions..js (module.js:416:10)                                          
at Module.load (module.js:343:32)                                                            
at Function.Module._load (module.js:300:12)                                                  
at Function.Module.runMain (module.js:441:10)                                                
at startup (node.js:139:18)                                                                  
at node.js:968:3                                                                             


2 Answers

Marissa Richardson
Marissa Richardson
47,541 Points

I see a missing opening double quote. From my notes the code looks like this:

var request = http.get("http://teamtreehouse.com" + username + ".json", function(response) { console.log(response.statusCode); });
request.on("error", function(error) { console.error(error.message); });

Most of the issue as mentioned by Marissa stems from you missing your opening double quote. missing this is making the code think that teamtreehouse.com is actually an object of unknown type. It is also making other parts of your code look like string that shouldn't be. From the look of your code just adding the double quote back to the start of your http.get() should fix your code and allow you to get an error.

Hope this helps. Good Luck in your studies.