Roudy Antenor4,124 Points
What is the meaning of require() ?
Can someone please explain why we need to const http = require (http) - What is the meaning of this step? Why do we need to require anything? Explanations on the web are complicated to me
Greg Kaleka38,983 Points
The thing you’re requiring requiring,
http, is a module, or essentially a chunk of code someone else wrote that you’re going to use. In order to use it you have to pull it into your file. The
require function does that for you. By storing the result of
require in a variable (which you could call anything you want, but in this case also
http), you can use that module more easily later in your code.
You’ll see this in a lot of programming languages. It’s sometimes called
Hope that makes sense!
Routine Poutine23,045 Points
If you can call the require variable anything, is this the only thing you will be requiring?
Import seems to have many different things you can import; is require only requiring https modules?