How to check the npm packages installed on your computer

When you add the --global or -g flag when running the npm install command, then the package will be installed globally.

Without the --global flag, then the npm package will be installed locally inside the node_modules/ folder of the current directory.

To check for all packages that are installed globally, you need to run the npm list command with the --global or -g flag as shown below:

npm list -g

The output in the terminal reveals the package name and the version installed as follows:

$ npm list -g
/Users/nsebhastian/.nvm/versions/node/v16.13.0/lib
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

To check for all packages that are installed locally, run the npm list command from the root directory of your project.

Suppose you have a project called vue-app. You need to run npm list from the vue-app/ folder like this:

vue-app $ npm list
[email protected] /Users/nsebhastian/Desktop/DEV/vue-app
├── @babel/[email protected]
├── @babel/[email protected]
├── @vue/[email protected]
├── @vue/[email protected]
├── @vue/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Keep in mind that if you’re using npm below version 7, then the npm list command will also show the related dependencies below the first level.

Here’s the same output of the vue-app dependencies using npm version below 7:

$ npm list
[email protected] /Users/nsebhastian/Desktop/DEV/vue-app
├─┬ @babel/[email protected]
│ ├─┬ @ampproject/[email protected]
│ │ ├─┬ @jridgewell/[email protected]
│ │ │ ├── @jridgewell/[email protected]
│ │ │ └── @jridgewell/[email protected]
│ │ └─┬ @jridgewell/[email protected]
│ │   ├── @jridgewell/[email protected]
│ │   └── @jridgewell/[email protected] deduped
│ ├─┬ @babel/[email protected]
│ │ └─┬ @babel/[email protected]
│ │   ├── @babel/[email protected] deduped
│ │   ├── [email protected] deduped
│ │   └── [email protected]
│ ├─┬ @babel/[email protected]
│ │ ├── @babel/[email protected] deduped
# ... the rest omitted

As you can see, the default output from npm list command above is intimidating. It’s hard to figure out what’s installed in your project.

When you only need the top-level dependencies, add the --depth=0 option to the command:

$ npm list --depth=0
[email protected] /Users/nsebhastian/Desktop/DEV/v-app
├── @babel/[email protected]
├── @babel/[email protected]
├── @vue/[email protected]
├── @vue/[email protected]
├── @vue/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Since npm version 7, the --depth=0 option has been added to the npm list command by default.

Now you know how to check what npm packages are installed on your computer, both globally and locally. Nice work! 👍

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.