Full-Stack Web Development with Vue.js and Node

(singke) #1
Building an Express Application Chapter 2

This is because these are the Express.js dependencies for any application. This means, when
we create an application using the express command, it will automatically install all the


dependencies that it needs. For example, the dependencies listed in the
preceding package.json file do the following things:


body-parser: This is used to parse the parameters of the body that we provide
when making an HTTP request
debug: This is a JavaScript utility package that provides pretty formatting to
what console.log returns

We can install or remove packages via the package.json file
as well. Just add or remove the name of the package in the
package.json file to install or remove it. Then run $ npm
install.

express: This is a Node.js JavaScript framework and is used for building scalable
web applications on top of Node.js.
jade: As mentioned previously, this is the default templating engine for Node.js.
We should have seen a warning while creating the application with the express
command, saying The default view engine will not be jade in future releases.
This is because jade is going to be replaced by pug; jade was copyrighted by a
company and the name was later changed to pug.

The express generator uses the outdated jade templating engine. To change the
templating engine, run the following steps:


  1. In the package.json file, remove the "jade": "~1.11.0", line and run:


$ cd express_app
$ npm install


  1. Now, to install the new pug templating engine, run:


$ npm install pug --save


  1. If we look into the package.json file, we should see a line similar to this:
    "pug": "^2.0.0-rc.4".

Free download pdf