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 Handling Routes in Node.js User Route

troy beckett
troy beckett
12,035 Points

Require HTTP

Why do we require "http" in both profile.js and app.js?

Jonathan Leon
Jonathan Leon
18,813 Points

From my understading, the http module is "native" and you can require it / declare it as variable from any file. the reason you'd do it in both files is because the variables won't "export" unless you choose to (for example , you choose to export the functions themselves, which run independatly).

I'm not sure it's the correct answer as I'm just learning this now but if someone could clarify it in a more professional way it would be great.