What is Node
How to Install Node
Building a Hello World App
Node Modules and Node Package Manager
File System in Node
Creating Web Server Using Express
Node and Databases
Create a new folder and switch to it using a terminal or command prompt.
Create a new node project using the following command.
This will create a sample package.json for your project.
To install express module, run the following command.
The latest version of the express framework will be installed in your project.
Now create a new file and name it app.js.
In this file, we will write our web server using express.
const app = express();
app.listen(process.env.port || 3000);
console.log('Web Server is listening at port '+ (process.env.port || 3000));
In the code shown above, we have required the express module and created a new instance of it. In the end, we have started our Server using the listen() function.