Create a simple Node.Js application using the Express framework using the following steps.
- Create a folder with the name NodeFirstApp.
- Open the folder in Visual Studio Code.
- Open Terminal
- Type Command npm init (It will initialize package.json). Just enter the questions they all are optional.
- Create a File with the name index.js and add the below code to it.
const express = require("express");
const app = express();
app.get('/', function (req, res) {
res.send("Hello Node JS");
})
app.listen(3000, function () {
console.log("Running on port 3000");
})
6. Run the code by typing the command Node index.js
Output: