Below is the simple syntax to use any Node.js module
let os = require('os');
console.log("This is the user info - " , os.userInfo());
Now here , we saw that to use the already existing function of os
module we just had to use simple dot notation. And we got it by writing os.userInfo()
.
However , in case of using Express.js , below is the procedure :-
let express = require('express'); //
let app = express(); // Line 1
app.listen(\\Write_Code);
I want to know that why do we have to write let app = express();
in case we are using Express.js
Afterall , we are importing express module also. So we should be able to use it's function like
express.app.listen()
or maybe like express.listen()
. I know app
is a variable present in Express module , but I am not able to understand Why do we have to write let app = express();
.
Can anyone please let me know like what is happening when we write let app = express();