Naveera A.
—Most modern JavaScript apps use a bunch of third party packages. Many packages are installed globally too.
How do you find the installed versions of the various npm
packages?
All locally installed npm
packages are listed in the package-lock.json
file. For a smaller project, you can take a quick look at this file.
An easier way to find the installed versions of npm
packages that doesn’t require so much visual scanning is to use the built-in command list
:
$ npm list
This command will print all the versions of packages that are installed in the current directory to stdout
, like so:
$ npm list projectName@projectVersion /path/to/project/folder ├── futil@1.69.0 └── lodash@4.17.21
If you want to see all the dependencies of manually installed packages and their versions, you can use --all
:
$ npm list --all projectName@projectVersion /path/to/project/folder ├─┬ futil@1.69.0 │ ├─┬ babel-polyfill@6.26.0 │ │ ├─┬ babel-runtime@6.26.0 │ │ │ ├── core-js@2.6.12 deduped │ │ │ └── regenerator-runtime@0.11.1 │ │ ├── core-js@2.6.12 │ │ └── regenerator-runtime@0.10.5 │ └── lodash@4.17.21 deduped └── lodash@4.17.21
You can also control the depth of level to show by using --depth
. For example, using --depth=1
will show the following:
$ npm list --depth=1 projectName@projectVersion /path/to/project/folder ├─┬ futil@1.69.0 │ ├── babel-polyfill@6.26.0 │ └── lodash@4.17.21 deduped └── lodash@4.17.21
Notice that any dependencies that are more than two levels deep are removed from the tree.
If you want to take a look at globally installed packages, you can use -g
, like so:
$ npm list -g /path/to/node/v16.15.1/lib ├── corepack@0.10.0 └── npm@8.12.1
To find the version of a specific package, specify its name:
$ npm list futil projectName@projectVersion /path/to/project/folder └── futil@1.69.0
To check the latest available version of the package on the npm repository, use the view
option:
$ npm view futil --version 8.12.1
Besides these, there are a few other options that can be used with list
. You can take a look at all available options in the official documentation.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at compliance@sentry.io.
If you are a California resident, see our Supplemental notice.