Home »
Node.js
Express template generator for your projects (1)
Express template generator: Here, we are going to see how we can generate a prepared template for express projects?
Submitted by Godwill Tetah, on June 25, 2019
Hello! After working with NODE.JS/EXPRESS several times, it's always stressful starting up a new project...since you need to rebuild the structure of your express application.
There is a tool called express generator which automatically generates a standard structure or template for an express application.
Express generator is a tool that helps us build a standard structure or template of the express application with some code to start up.
It includes all required modules and dependencies which you'll later install and use.
There are many procedures, but this article gives one of the easiest.
Take Note! You should have Node.js installed in your computer.
With Node.js already up and running, let's get started.
Let's see how the structure looks like:
Let's generate our own express template now,
- First install the express generator module at the command line in your node project directory.
- Wait for a while as npm installs the module.
- The syntax for creating an express template is by typing express <app name> at the command line.
- For example: express myapp will create an express template folder called myapp found in your node.js project directory.
- Move to the myapp folder using the command cd myapp
- Finally, when you're in the myapp directory, run the command npm install which will install all the modules and dependencies for the project.
- On the command promt (still in the app directory), type npm start to initiate/ start your express app.
- The port number will be printed out on the console.
- You can also check/change the server details in the bin folder, www file.
- Right click the file and open it in a text editor to view or edit server details.
Thanks for coding with me. Your comments are most welcome.