To advertise with us contact on Whatsapp: +923041280395 For guest post email at:

Easy Node JS Environment Settings for Express Framework

Easy Node JS Environment Settings for Express Framework

To proceed towards web development using Express JS, you will follow a few steps to setup the environment on your computer (in case of localhost) or server. The steps are given below:

How to download & install Node JS & Node Package Manager (NPM)?

Node JS and Node Package Manager (NPM) supports a variety of operating systems including Linux, macOS and Windows. Once Node JS and NPM get installed successfully, you will be able to install Express JS and proceed towards creating a web project.

How do I download Node JS?

Use the following link to download setup of the current stable version of node and npm. This setup will automatically install node and npm on your system.

download screen node js
Official Website Screenshot for download Node JS with NPM

You will see the above screen after visiting the given link. Click to download the setup compatible with your system and double click the downloaded file to run it. When it is opened, you may be asked to grant running the program with administrator rights. Allow it and click next to install. Tick the checkbox to agree with terms of service and click next. After it select the directory and click next. After it, select all the packages including node js and node package manager (npm) and click next. Now you will see a install button. Click this button and installation will start. After completion of installation process, click finish to end.

How do I check node version and npm version?

After installation finishes, you may execute the following commands on command prompt in case of Windows and terminal in case of Linux, to confirm the installation of node and npm.

node --version
npm --version

In case, if you don’t see the output as given below, try to reinstall and recheck.

install node js and npm

Node Package Manager (NPM)

Node Package Manager (npm) is publicly accessible open source code collection for web app, mobile app, robots, routers etc. You may download and install these packages via command line through npm install commands. There are two ways given below to install via npm command.

Global installation of NPM

If you want to install any package globally which you want to use in all of your Express JS projects, you may use the command below where -g means globally installed. Mostly command line and development tools are installed globally.

npm install -g <package name>

Local installation of NPM

If you want to install a package only in your single project, you may execute the command below. This method is applicable when you have to install frameworks and libraries.

npm install <package name>

How to create Express JS project?

After setting up environment variables, you will need to create project. In Express JS, when we have to create a project, we create a package.json file which contains details about the libraries and project. The file helps us to keep record of required libraries and we can install our project with npm install command. To create package.json, follow the steps below:

Step 1: Creating Folder

How to create directory in Windows?

If you are using Windows 10 or any other Windows version, create a folder. Now open the created folder, hold shift key and right click. You will see option Open PowerShell window here. Click this option, command prompt pointed to your created folder will be opened.

open directory in terminal
Command Prompt

How to create directory in Linux ?

If you are using Linux OS, you will create directory and navigate to directory by executing commands below:

$ mkdir node-project
$ cd node-project
create directory in linux

Step 2: Creating package.json

Now for creation of package.json file, execute the command below.

$ npm init

Now you will be asked about various values like package name, version, description, test command, git repository, keywords, author, license etc. If you are a completely beginner, you may keep entering on all the questions. You can write your name when you are asked about author. However, if you are learning just to create package.json and you have previous experience then you may change values as per your choice.

Step 3: Install Express and add record to package.json

Whenever you install framework, library or package from npm, always use –save or -S in your installation command because this will add record in package.json and you will be able to install required packages on server by just using npm install command. To install Express JS, execute the command below:

$ npm install --save express

The above command will install node_modules folder in your directory. To confirm this on Linux, you may list files in node_modules by the command below:

$ ls node_modules

In case, you have missed –save in your command, you will need to install required dependencies on your server manually. So, remember to use –save in your command.package.json looks like below in my computer.

  "name": "setuts",
  "version": "1.0.0",
  "description": "An online tutorials website for textual and video tutorials.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "Arslan ud Din Shafiq",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.4"

Step 4: Install Nodemon

Now I will recommend to install nodemon package globally because it will make development easier by restarting your server whenever a change is made in files. Without nodemon, you will need to restart server manually after each update. For installing nodemon, execute the command below:

$ npm install -g nodemon

Now you have successfully setup environment for Express JS. You may proceed towards next tutorial for creating our first Express JS application hello-world.

Leave a Reply

Your email address will not be published. Required fields are marked *