
To execute our Node application using Nodemon, you type in the command line:įrom now going on, all you can do is to save all your changes and let Nodemon takes care of restarting the web server for you. You can name your key value to anything, in my case I named it app. Once done installing, go to the package.json file and add the following under script: Nodemon automates the process of restarting our Node project each time we save changes. It is not an efficient way to develop Node applications because each time we make changes, we have to stop the webserver, save changes, and execute the same command. We executed node app.js in the terminal to get this output. The web server const express = require('express') const app = express() app.listen(3000, () => console.log(“Listening on port 3000”))

In this file, we create an HTTP server and it listens on port 3000. We are ready to start! Let’s create the app.js file in the root folder. Express is a middleware web framework that handle routes, requests and responses. The dependencies we just installed serve different purposes.
#PUG TEMPLATE ENGINE INSTALL#
Let’s install Nodejs and other dependencies we need in the project, once it is done running it adds node modules folder and package-lock.json file: Every dependency you add in this project will show in the package.json file. You have successfully created a package.json file, located in the root folder of your project, for project identification and contain dependencies we will install add. package name: (newproject) version: (1.0.0) description: entry point: (index.js) app.js test command: git repository: keywords: author: license: (ISC) The dependencies However you can specify all the fields, read more about the content of the package.json fields here to make informed changes.
#PUG TEMPLATE ENGINE CODE#
By running the code below, we initiate our project by creating a package.json file.Īs shown below, I did not change anything except entry point, I changed from index.js (default) to app.js.

I recommend using the terminal in vsCode because it is easier to access, you do not need to enter the path directory. Open the folder newProject in Visual Studio Code (VSCode).

Use the IDE of your choice, in my case I am using Visual Studio Code. Start by creating a folder in a directory of your choice using the terminal. In addition to the prerequisite mentioned above, you must be familiar with JavaScript. Click here to get Nodejs if you do not have one. To get hands on experience with this article you need to have:
#PUG TEMPLATE ENGINE HOW TO#
At the end of this tutorial, you would have created an single web page and learn how to use the technologies mentioned above. We will create a Node application from scratch, set up Nodejs, express, and a pug template engine. In this tutorial, I will explain how to use a pug template and NodeJS to build a web page. Image by Free-Photos from Pixabay Introduction
