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 trialUla Troc
1,881 PointsWhy are we saving require('express') and express(); in variables?
I was just wondering, what if we didn't save the express module in a variable. How would that affect the development?
What is the reason for saving it under const express and const app
1 Answer
Steven Parker
231,269 PointsThe variables just give you references you can use to access the features of the module. "express" is needed so you can call the module and assign "app". And "app" gives you access to the features, such as the "listen" function:
app.listen(3000); // example of using variable/constant to access module feature