Express and Express Generator

January 20, 2018 - server

Install Express and Express generator

npm install express --global
npm install express-generator -g

Check if it is succesfully installed:

express --help

Usage: express [options] [dir]
--version        output the version number
-e, --ejs            add ejs engine support
     --pug            add pug engine support
     --hbs            add handlebars engine support
-H, --hogan          add hogan.js engine support
-v, --view <engine>  add view <engine> support (dust|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
-h, --help           output usage information

Create scaffold – files and folders

-e supports .ejs view engine

express -e

It creates:


Install packages in package.json

npm install

Run app

package.json has a script called start

  "scripts": {
    "start": "node ./bin/www"

that enables us to start the app with:

npm start

View the page at http://localhost:3000/