Skip to content
thesarfo

Note

Express Generator

Scaffolding a new Express project with express-generator, its CLI options, and running the generated app.

views 0
Terminal window
npm install express-generator -g

The generator has a number of options, which you can view on the command line using the —help (or -h) command:

Terminal window
> express --help
Usage: express [options] [dir]
Options:
--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)
--no-view use static html instead of view engine
-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

You can specify express to create a project inside the current directory using the Jade view engine and plain CSS (if you specify a directory name then the project will be created in a sub-folder with that name).

Terminal window
express

see example below

Terminal window
express projectname --view=pug

After everything has been done

Terminal window
change directory:
> cd projectname
install dependencies:
> npm install
run the app (Bash (Linux or macOS))
> DEBUG=projectname:* npm start
run the app (PowerShell (Windows))
> $ENV:DEBUG = "projectname:*"; npm start
run the app (Command Prompt (Windows)):
> SET DEBUG=projectname:* & npm start