Step 10

Several libraries and frameworks are built on top of Node's HTTP module to improve and extend its functionality. ExpressJS is one of those frameworks. It promotes itself as a "fast, unopinionated, minimalist web framework for NodeJS." It is famous for building APIs quickly and easily.

We will now refactor our server to use Express instead of Node's HTTP module.

First, install it.

npm install express

Notice three changes as a result of installing Express:

  1. Express is added as a dependency to package.json
  2. The node_modules is added to the root directory. Make sure to exclude this folder from your Git repository.
  3. A package-lock.json is added to the root of your project.

You are familiar with all this, as you have seen them in previous chapters.