How to check the npm version installed on your computer (2024)

by Nathan Sebhastian

Posted on May 26, 2022

Reading time: 2 minutes

How to check the npm version installed on your computer (1)

Once you installed Node.js on your computer, you can check the version of npm that was bundled with it.

The command to check your npm version is npm -v or npm --version. Type it in your terminal and you should see the following output:

The output above means npm has been installed successfully on your computer.

Next, let’s see how you find the version of an installed npm package.

Find the version of an installed npm package

The version of npm packages installed on your computer can be found by running the npm list command.

First, navigate to the root directory of your project, then run the npm list command.

You should see the output below in your terminal:

$ npm list[emailprotected] /Users/nsebhastian/Desktop/DEV/n-app├── [emailprotected]├── [emailprotected]├── [emailprotected]├── [emailprotected]├── [emailprotected]└── [emailprotected]

The output above shows the packages installed in the node_modules/ folder.

If you’re using an older npm version, then you might see the list of all modules installed, including the dependencies of your top-level modules.

For example, here’s the output when I run npm list using npm v6:

$ npm list[emailprotected] /Users/nsebhastian/Desktop/DEV/n-app├─┬ [emailprotected]│ ├── [emailprotected]│ └── [emailprotected]├─┬ [emailprotected]│ ├─┬ [emailprotected]│ │ ├─┬ [emailprotected]│ │ │ └── [emailprotected]│ │ └── [emailprotected]│ ├── [emailprotected]# ...

The output above also shows the dependency packages installed for your modules, such as object-assign and vary installed as dependencies of the cors package.

To make npm show only the top-level modules, add the --depth=0 option to the npm list command:

$ npm list --depth=0[emailprotected] /Users/nsebhastian/Desktop/DEV/n-app├── [emailprotected]├── [emailprotected]├── [emailprotected]├── [emailprotected]├── [emailprotected]└── [emailprotected]

In the latest npm version, --depth=0 is the default option automatically added to the command, so you don’t need to add it anymore.

Check the version of globally installed npm packages

To check the version of globally installed npm packages, run the npm list command with the -g or --global option added.

Here’s an example:

$ npm list -g/Users/nsebhastian/node/lib├── [emailprotected]└── [emailprotected]

For older npm versions, you might want to add --depth=0 option to show only top-level modules:

npm list -g --depth=0/Users/nsebhastian/node/lib├── [emailprotected]└── [emailprotected]

And that’s how you check the versions of globally installed npm packages.

How to check the npm version installed on your computer (2024)
Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 6022

Rating: 4.2 / 5 (73 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.