Generating Express scaffolding

Express works both as a Node module and as a command-line executable. When we run express from the command line it generates a project skeleton for us, accelerating the preparation process.

Getting ready

We need to install express using the -g flag (install globally) in order to run the express executable from any directory.

sudo npm -g install express

We use sudo to ensure we get permission to install globally. This doesn't apply under Windows.

How to do it...

First, we decide upon the name of our app. Let's call it nca (Node Cookbook App) and simply do:

express nca

This will generate all of our project files under a new directory called nca. Before we can run our app, we must ensure that all dependencies are installed. ...

Get Node Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.