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 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.