It’s trivial to create an empty Node.js project using express generator using the command line. You can follow the guide found at this link for the official express generator example or just keep reading.
Begin by opening up your terminal and navigate to any folder on your file system. Keep in mind that the project will be created as a sub-directory of the folder you choose. If you haven’t installed express generator then execute the following command.
npm install express-generator -g
This command will install express generator on your system. Once the installation is complete, you can create an express project with the handlebars view engine using this command.
express --hbs [application name]
Replace [application name] with the name of your application. For example
express -hbs myhbsproject. The script will create a folder in the current directory that has the same name as your application. You should see terminal output that looks similar to the screen shot.
If you look closely, the script tells you the next two steps. First you need to install the dependencies.
cd [application name] npm install
Once again, npm will do the job of downloading all required project dependencies.
Finally, you can run the project by issuing the next command in the terminal.
DEBUG=[application name]:* npm start
You will see this output in the terminal.
When the server is running, you can open up your web browser and point it at http://localhost:3000/ to see the default homepage.
For those people who are curious, you will get the following folder structure when using express generator to create a project.
You can view the YouTube video here.