Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Protractor Tutorial 7 – NPM – Installing a Package Locally & Globally

Posted on 02/19/2025 By admin

Hello Folks,

In last post, we have already seen Installation of NPM in last post. In this post we will see below topics:-

  1. How to install a package using npm?
  2. What is local installation of package using npm?
  3. What is global installation of package using npm?
  4. How to install specific version of a package using npm?

We can install a NodeJS package globally or locally. So before I write a lengthy speech here, let’s do a practical and then understand it by its result.

We know like maven central repository, we have npm repository. We will install NodeJS package to read properties file.

Step 1:- Create a folder at some location and open terminal and navigate to newly created folder.

You can see I have created a folder in ‘G’ driver with name “MSE-NPMExample”. Currently it is empty.

Step 2:- We will install a NodeJS package named “properties-reader “. Let’s paste below command in cmd and hit enter:-

npm i properties-reader

OR

npm install properties-reader

You must have understand the format to install a package as:-

npm instal

Refer below image to understand package name:-

Now type the command and hit. You will see below screen:-

I have painted some lines in yellow. You will not understand exactly but don’t worry. I will cover those things.

Above command installs latest version of mentioned package, and any packages that it depends on. You should see “[email protected]” in above image. “0.0.16” is latest version of mentioned package which you can see in npm screenshot above. When you run above installation command , desired package is installed locally i.e. puts stuff in ./node_modules of the current package root. Let’s see if we see any folder named ‘node_modules’ in newly created folder named “MSE-NPMExample”.

You can see a JSON file with name “package-lock.json” is also created. You can see info about it in command terminal screenshot above also. We will see what it is later.

If you go into node-modules folder, you will see desired package has been installed with its sub-dependencies:-

“node-modules” is similar to “.m2” folder of Maven. It is local installation as node-modules folder is created within root folder and package is installed. If you want to manage dependency of a project locally and should not impact other projects, install package locally. We will see different and impact local and global installation of package later.

When you install a package locally, usage is restricted within that folder. You can install any package as globally as well. Use below syntax to install package globally:-

npm install -g

Global installation creates node_modules folder in /usr/local or wherever node is installed.

Let’s run above command and see where it puts stuff. Delete contents of folder “MSE-NPMExample” so that you can feel the difference.

***After installation of many packages, it gives you path where it got installed which we dont see for above package.

First navigate to folder “MSE-NPMExample “, you will see no node_modules folder is created.

Now navigate to below folder location:-

C:\Users\\AppData\Roaming\npm\node_modules

You will see node_modules folder here and properties-reader is installed here. This is called global installation of a package.

I am running above commands in windows machine, so global path will be different for other operating system. You can list all globally installed package using below command:-

npm list -g OR npm list –global

Above command gives you the location of global installation as well. It will be helpful for whatever operating system you are using.

npm install installs latest version of package. If you want to install a specific version of package use below command:-

npm install @version

e.g. npm install [email protected]

You can find all available version in npm page of package:-

We will see more about it in upcoming posts. Stay tuned.

#ThanksForReading

Uncategorized

Post navigation

Previous Post: Usage of Java Stream API in Selenium – Retrieving Unique Text From a List Of WebElements
Next Post: Navigate And Fetch Title Of All Tabs Using Selenium WebDriver

Related Posts

image – Make Selenium Easy Uncategorized
Make Selenium Easy – Page 16 Uncategorized
How To Iterate Map In Java? Uncategorized
Postman Tutorial Part 16 – Introduction To Collections In Postman Uncategorized
Part 10: Usages Of Javascripts In Selenium: How To Capture Screenshot Of Entire Web Page Uncategorized
How to Fluent With FluentWait in Selenium WebDriver? – Part 1 Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark