We now have a youtube channel. Subscribe!

Express.js | Environment

Express.js | Environment

Hello folks! Welcome back to a new edition of our tutorial on Express.js. In this tutorial guide, we will learn how to start developing and using the Express Framework.

To start with, you should have the Node and the npm (node package manager) installed. In the case you don't already have these, go to the Node setup to install node on your local computer. Confirm that node and npm are installed by simply running the following commands in your terminal.

node --version
npm --version

You should get an output similar to the one below.


Now that we have Node and npm set up, let us understand what npm is and how we can use it.

Node Package Manager(npm)

npm is the package manager for node. npm registry is a public collection of packages of open-source code for Node.js, frontend web apps, mobile apps, robots, routers and other endless needs of the JavaScript community. npm allows us to access all these packages and install them in our local machines. You can browse through all the list of packages available on npm at npmJS.

How to use npm?

There are two ways of installing a package using npm: globally and locally.


This method is generally used for installing development tools and CLI based packages. To install a package globally, make use of the following code.

npm install -g <package-name>


This method is generally used for installing frameworks and libraries. A locally installed package can be made use of only within the directory it is installed. To install a package locally, use the following command below.

npm install <package-name>

Whenever we create a project utilizing npm, we need to give a package.json file, which has all the details about our project. npm makes it easy for us to set up this file. Let's set up our development project.

First Step - Start your terminal/cmd, create a new folder and name it hello-world and cd (create directory) into it -


Second Step - To create the package.json file using npm, use the following code.

npm init

It will ask you for the following information.


Keep pressing enter, and enter your name at the "author name" field.

Third Step - Now we have our package.json file set up, we will further install Express. To install Express and add to our package.json file, use the following command -

npm install --save express

To confirm that Express has correctly been installed, run the following code.

ls node_modules #(dir node_modules for windows)

Tip - The --save flag can be replaced by the -S flag. This flag makes sure that Express is added as a dependency to our package.json file. This has an advantage, the next time we need to install all the dependencies of our project, we can just run the command "npm install" and it will locate the dependencies in this file and install them for us.

This is all we need to start development via Express Framework. For our development process to be a lot easier, we'll install a tool from npm, nodemon. This tool restarts our server as soon as we make a change in any of our files, otherwise we need to restart the server manually after each file modification. To install nodemon from npm, make use of the following command -

npm install -g nodemon

You can now begin working on Express.

Alright guys! This is where we are going to be rounding up for this tutorial. In our next tutorial, we are going to be creating our first Express application.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain