EN
Express.js - create new project
3 points
In this article, we would like to show you how to create new project for Express.js.
Prerequirements:
- installed Node.js on used computer
Installation instruction:
Simple steps:
- create new directory,
- open terminal and go to the diretory,
- create package.json file using the command:
xxxxxxxxxx
1npm init -y
Note:
-y
flag makes default values using, so we won't need to answer any questions. - install express package using the command:
xxxxxxxxxx
1npm i express
- create index.js file inside the directory and use source code:
xxxxxxxxxx
1const express = require('express'); // imports Express.js module
2
3const app = express(); // initializes application
4
5app.listen(5000); // runs server on specified port
- run index.js fil using the command:
xxxxxxxxxx
1node index.js
- open the link http://localhost:5000 in a web browser.
Screenshot:
