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.
Folder Structure
For those people who are curious, you will get the following folder structure when using express generator to create a project.
The public folder is for files such as client side javascript, css, and images that can be referenced by a web page. You should put your server js in the routes folder. All handlebar template files should get placed in the views folder.
You can view the YouTube video here.
You can view a tutorial one how to create a project at this link or use your […] […] that resembles the one shown in this screenshot.
LikeLiked by 1 person
You can view a tutorial one how to create a project at this link or use your […] […] that resembles the one shown in this screenshot. You can view a tutorial one how to create a project at this link or use your […]
LikeLike
[…] to the one shown in the following screenshot. You can view a tutorial one how to create a project at this link or use your […] […] that resembles the one shown in this screenshot.
LikeLike
You can view a tutorial one how to create a project at this link or use your […] json […]
LikeLiked by 1 person
You can view a tutorial one how to create a project at this link or use your […] You can view a tutorial one how to create a project at this link or use your […] json […]
LikeLike
You can view a tutorial one how to create a project at this link or use your […] You can view a tutorial one how to create a project at this link or use your […] json […] You can view a tutorial one how to create a project at this link or use your […]
LikeLike