How to Find the Installed Version of an npm Package
Knowing the version of a specific package installed in your application is essential for various reasons. Here are a few methods to help you find out the installed version of an npm package.
To see the latest version of all the npm packages installed, along with their dependencies, you can use the following command in your terminal:
1 | npm list |
For example:
1 | ❯ npm list |
Another option is to open the package-lock.json
file and visually scan for the package version. However, this method can be time-consuming.
If you want to check globally installed packages, you can use the -g
flag with the npm list
command. For example:
1 | npm list -g |
To get only the top-level packages, which are the ones specified in your package.json
, you can run the following command:
1 | npm list --depth=0 |
For example:
1 | ❯ npm list --depth=0 |
If you want to find the version of a specific package, you can use the package name as an argument with the npm list
command. For example:
1 | npm list <package_name> |
For example:
1 | ❯ npm list cowsay |
This method also works for the dependencies of the packages you have installed. For example:
1 | ❯ npm list minimist |
If you want to check the latest available version of a package in the npm repository, you can use the npm view
command followed by the package name and the keyword version
. For example:
1 | npm view [package_name] version |
For example:
1 | ❯ npm view cowsay version |
By using these methods, you can easily find the installed version of the npm packages in your application.
tags: [“npm”, “package”, “version”, “dependencies”]