How to create a Node.JS application with Express Generator

I am assuming that you already have Node.JS installed. If you don’t, worry not! you can get your own copy today from the Node.JS download section!

Using ExpressJS is very quick and easy. It generates all the file structure needed for a web application. You can select any of the different views they have available, in this case I am using PUG. The steps below will guide you through the process.

Step 1

Install ExpressJS globally like so:

npm install -g express-generator

Step 2

Create a ExpressJS application. Note that the name of my application is MyApplication, well understood you should replace MyApplication for the name of your own application when running the following command:

Z:\Code\NodeJS>express --view=pug MyApplication

Your console output should be similar to this:

create : MyApplication\
create : MyApplication\public\
create : MyApplication\public\javascripts\
create : MyApplication\public\images\
create : MyApplication\public\stylesheets\
create : MyApplication\public\stylesheets\style.css
create : MyApplication\routes\
create : MyApplication\routes\index.js
create : MyApplication\routes\users.js
create : MyApplication\views\
create : MyApplication\views\error.pug
create : MyApplication\views\index.pug
create : MyApplication\views\layout.pug
create : MyApplication\app.js
create : MyApplication\package.json
create : MyApplication\bin\
create : MyApplication\bin\www

change directory:
> cd MyApplication

install dependencies:
> npm install

run the app:
> SET DEBUG=MyApplication:* & npm start


Step 3

Go inside your application directory (exactly where the package.json file is located) and run the following command:

Z:\Code\NodeJS\MyApplication>npm install

Your console output should be similar to this:

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

> core-js@2.6.11 postinstall Z:\Code\NodeJS\MyApplication\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
Also, the author of core-js ( ) is looking for a good job -)
npm notice created a lockfile as package-lock.json. You should commit this file.
added 119 packages from 174 contributors and audited 247 packages in 7.793s
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details


Boom! it’s done!