Steps to use middleware chaining in Express JS
Step 1: In the first step, we will create the new folder by using the below command in the VScode terminal.
mkdir folder-name
cd folder-name
Step 2: After creating the folder, initialize the NPM using the below command. Using this the package.json file will be created.
npm init -y
Step 3: Now, we will install the express dependency for our project using the below command.
npm i express
Step 4: Now create the below Project Structure of our project which includes the file as app.js.
Project Structure:
The updated dependencies in package.json file will look like:
"dependencies": {
"express": "^4.18.2"
}
How to run Node/Express on a specific port?
Port in Node is the numerical endpoint that is assigned to the process to allow communication over the network. Each application is identified uniquely by using this port number. There are port numbers that range from 0 to 65535, some of the ports are already assigned to the common services. In this article, we are going to learn how we can run a node on a specific port rather than using the default port. We will run a node on a specific port by using the two approaches.
Contact Us