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 Making a GET Request with http

John Lukacs
John Lukacs
26,210 Points

profile.js:4 Uncaught ReferenceError: require is not defined at profile.js:4 I am still getting a error

This is what it says in the console profile.js:4 Uncaught ReferenceError: require is not defined at profile.js:4 this is the line of code I have done everything that was asked why is this not working for me

var http = require("http");

4 Answers

John Lukacs
John Lukacs
26,210 Points

Why does this Node.js course not work when you do this out of workspaces and on your computer. I don't understand; why teach something that only works in workspaces

John Lukacs
John Lukacs
26,210 Points

I get the error require is not defined. I thought I made the variable http so why is it not defined

David Olson
David Olson
8,690 Points

Hey John, Try posting all your code? Also if you are not using workspaces are you sure you have installed node correctly? at a command line type node -v to see what version you have. If you dont, here are the guides below.

http://blog.teamtreehouse.com/install-node-js-npm-linux http://blog.teamtreehouse.com/install-node-js-npm-mac http://blog.teamtreehouse.com/install-node-js-npm-windows

Ryan Wittrup
Ryan Wittrup
9,156 Points

Hi John - not sure if you're still stuck on this or found a fix.

Would you be able to post your full code and what editor you're using?

That error would typically occur if implemented on the browser side, since there is no "require" method available to the browser, only server side.