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 Node.js Basics (2014) Building a Command Line Application Perfecting: Getting Multiple Profiles

ReferenceError: http is not defined...

I've copied and pasted the solution DIRECTLY from the file downloads provided by the instructor and I'm using Notepad++. When I run node for the files I receive the "ReferenceError: http is not defined" message. What would be a typical reason for this happening? Like I said, these are direct copies of the official solutions provided for the Node.js course. Thanks.

3 Answers

Hi Tyrel,

Literally, that error means that you are using a variable called http in your code that was never initialized. Without you posting the actual code, however, there is no way to accurately diagnose the underlying problem.

David Anton
PLUS
David Anton
Courses Plus Student 30,936 Points

You must define the http at the top of your code, and require the node http module.

Example:

    var http = require("http");
Nemanja Miljkovic
PLUS
Nemanja Miljkovic
Courses Plus Student 15,034 Points

Hi,

u must change http request with https request because few years ago Treehouse has changed protocol to https. Because protocol has changed url of json file has changed also to 'https://teamtreehouse.com/chalkers.json'.