Express installation

Assuming you have already installed Node.js while following the previous chapters and have updated npm, you can either add Express.js to any specific project or install it globally. The following code lets you add Express.js to any specific project:

$ npm install express

The following command lets you install it globally:

$ npm install express -g
Note that in Linux machines you have to run this command as root.

There is also a possibility to install a plugin called express-generator, which is an express application generator tool that generates an application skeleton quickly. The command to install it is as follows:

$ npm install express-generator -g

The list of available commands from express-generator can be seen by typing the following:

$ express -h

Usage: express [options] [dir]

Options:

-h, --help output usage information
--version output the version number
-e, --ejs add ejs engine support
--hbs add handlebars engine support
--pug add pug engine support
-H, --hogan add hogan.js engine support
--no-view generate without view engine
-v, --view <engine> add view <engine> support (ejs|hbs|hjs|jade|pug|twig|vash) (defaults to jade)
-c, --css <engine> add stylesheet <engine> support (less|stylus|compass|sass) (defaults to plain css)
--git add .gitignore
-f, --force force on non-empty directory

It is highly recommended that you walk through the Express.js documentation, which is available at https://expressjs.com/en/4x/api.html, to get a better understanding of it.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.233.41