Npm View

Summary: in this tutorial, you will learn how to use the npm view command to show data about a package.

To view the information of a package, you typically go to the npmjs.com website, find the package name, and display its information.

The npm CLI tool provides the npm view command that allows you to quickly show the information on a package on the terminal.

Introduction to npm view Command

The npm view command returns the information on a package:

npm view <package_name>[@<version>] [<field>?][<.subfield>]Code language: Shell Session (shell)

The npm view command has the following aliases npm info, npm show, and npm v.

For example, to show the information about the express package, you use the following command:

npm view express
Code language: Shell Session (shell)

By default, the npm view command returns the latest version of the package if you don’t specify it in the package name.

To show the information of the express package version 4.17.1, you use this command:

npm view [email protected]Code language: Shell Session (shell)

To show specific information on a package, you specify that information after the package name in the form of a field name. For example, the following command shows only dependencies of the express package:

npm view express dependenciesCode language: Shell Session (shell)

You can view the subfield of a field using the format field.subfield. For example, to view the repository URL of the express package, you use the following command:

npm view express repository.urlCode language: Shell Session (shell)

The following command shows the contributor emails of the express package:

npm view express contributors.emailCode language: Shell Session (shell)

To format the output in JSON, you use the --json flag. For example:

npm view express contributors --jsonCode language: Shell Session (shell)

Summary

  • Use the npm view command to show information on a package.
Was this tutorial helpful ?