Skip to content
Related Articles

Related Articles

How to find the version of an installed npm package in node.js ?
  • Last Updated : 11 Feb, 2021

NPM  is a default package manager for Node.js. NPM manages all the internal as well as external packages or modules that we use in various node.js applications. Default Packages in NPM cannot fulfill the needs of the developer, so we need external packages, and we can install either locally in a particular directory on our machine or globally that are easily accessible in any location on our machine. 

Installing npm package locally using the below command: This command will install the mentioned package in our local directory.

npm install <package-name> 

Installing npm package globally using the below command: This command will install the mentioned package globally. Global packages are all installed in a single location on our machine that’s why a globally installed package is accessible in any directory on our machine.

npm install -g <package-name>

Methods to check the installed version of Node.js. packages on our machine:



  1. Checking locally installed  Node.js packages in a particular directory using the below command.

    npm ls

    Output:

  2. Checking globally installed packages on our machine using the below command.

    npm list -g

    Output:

  3. Checking specific package globally installed node.js package using below command.

    npm ls -g <package_name>

    Output:

  4. Checking Local top-level domain of packages only and not all sub-packages using the below command.

    npm list --depth=0

    Output:

  5. Checking Globally Top-level domain node.js packages using the below command.

    npm list --depth=0 -g

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :