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:

npm list

For example:

❯ npm list
/Users/flavio/dev/node/cowsay
└─┬ [[email protected]](/cdn-cgi/l/email-protection)
 ├── [[email protected]](/cdn-cgi/l/email-protection)
 ├─┬ [[email protected]](/cdn-cgi/l/email-protection)
 │ ├── [[email protected]](/cdn-cgi/l/email-protection)
 │ └── [[email protected]](/cdn-cgi/l/email-protection)
 ├─┬ [[email protected]](/cdn-cgi/l/email-protection)
 │ ├── [[email protected]](/cdn-cgi/l/email-protection)
 │ └─┬ [[email protected]](/cdn-cgi/l/email-protection)
 │ └── [[email protected]](/cdn-cgi/l/email-protection)
 └── [[email protected]](/cdn-cgi/l/email-protection)

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:

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:

npm list --depth=0

For example:

❯ npm list --depth=0
/Users/flavio/dev/node/cowsay
└── [[email protected]](/cdn-cgi/l/email-protection)

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:

npm list <package_name>

For example:

❯ npm list cowsay
/Users/flavio/dev/node/cowsay
└── [[email protected]](/cdn-cgi/l/email-protection)

This method also works for the dependencies of the packages you have installed. For example:

❯ npm list minimist
/Users/flavio/dev/node/cowsay
└─┬ [[email protected]](/cdn-cgi/l/email-protection)
 └─┬ [[email protected]](/cdn-cgi/l/email-protection)
 └── [[email protected]](/cdn-cgi/l/email-protection)

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:

npm view [package_name] version

For example:

❯ npm view cowsay version

1.3.1

By using these methods, you can easily find the installed version of the npm packages in your application.