NodeMon and Express

Nodemon - No need to restart the app after changes.

Express.js allows us to add custom middleware functions that can perform specific tasks, such as logging, authentication, and more. It provides a simple way to handle HTTP requests and responses, allowing you to easily create REST APIs and other types of web services.

To install nodemon and use it with app.

  1. Install nodemon globally:

npm install -g nodemon
  1. Create a new Express.js app:

npm init -y
npm install express
package.json
{
  "name": "name",
  "version": "1.0.0",
  "description": "None",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon app.js",
    "start-server": "node app.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2",
    "nodemon": "^2.0.20"
  }
}
app.js

const http = require('http');
const express = require("express")
const app = express();

const server = http.createServer(app)

server.listen(3000);

Last updated