Last updated on

Express.js is a fantastic web framework for new developers to get an app started quickly and it’s certainly one of the most popular frameworks available.

You can of course just add Express as a dependency to an existing project and start creating your own routes and templates etc. but there is a tool available, the Express Generator, which can build a skeleton project with routes and templates separated into their own folders .

Installing the Express Generator

Simply install the Express Generator as a global npm package:

npm install -g express-generator

Once installed, to use it simply call the command express with a project name from the terminal:

express my-new-project

Passing options to Express Generator

There are a few options that you can pass to the Express Generator program:

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

The main ones being the templating engine you want to use to render templates for your routes.

I prefer –ejs Embedded JavaScript as it’s quite a common form of template and it’s simple to use although Handlebars has some nice features too 🙂

Try them both out and see what you prefer.