11cb0ef41Sopenharmony_ci---
21cb0ef41Sopenharmony_cititle: npm-view
31cb0ef41Sopenharmony_cisection: 1
41cb0ef41Sopenharmony_cidescription: View registry info
51cb0ef41Sopenharmony_ci---
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### Synopsis
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci```bash
101cb0ef41Sopenharmony_cinpm view [<package-spec>] [<field>[.subfield]...]
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cialiases: info, show, v
131cb0ef41Sopenharmony_ci```
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci### Description
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciThis command shows data about a package and prints it to stdout.
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciAs an example, to view information about the `connect` package from the registry, you would run:
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci```bash
221cb0ef41Sopenharmony_cinpm view connect
231cb0ef41Sopenharmony_ci```
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciThe default version is `"latest"` if unspecified.
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciField names can be specified after the package descriptor.
281cb0ef41Sopenharmony_ciFor example, to show the dependencies of the `ronn` package at version
291cb0ef41Sopenharmony_ci`0.3.5`, you could do the following:
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci```bash
321cb0ef41Sopenharmony_cinpm view ronn@0.3.5 dependencies
331cb0ef41Sopenharmony_ci```
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciBy default, `npm view` shows data about the current project context (by looking for a `package.json`).
361cb0ef41Sopenharmony_ciTo show field data for the current project use a file path (i.e. `.`):
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci```bash
391cb0ef41Sopenharmony_cinpm view . dependencies
401cb0ef41Sopenharmony_ci```
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ciYou can view child fields by separating them with a period.
431cb0ef41Sopenharmony_ciTo view the git repository URL for the latest version of `npm`, you would run the following command:
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci```bash
461cb0ef41Sopenharmony_cinpm view npm repository.url
471cb0ef41Sopenharmony_ci```
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciThis makes it easy to view information about a dependency with a bit of
501cb0ef41Sopenharmony_cishell scripting. For example, to view all the data about the version of
511cb0ef41Sopenharmony_ci`opts` that `ronn` depends on, you could write the following:
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci```bash
541cb0ef41Sopenharmony_cinpm view opts@$(npm view ronn dependencies.opts)
551cb0ef41Sopenharmony_ci```
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ciFor fields that are arrays, requesting a non-numeric field will return
581cb0ef41Sopenharmony_ciall of the values from the objects in the list. For example, to get all
591cb0ef41Sopenharmony_cithe contributor email addresses for the `express` package, you would run:
601cb0ef41Sopenharmony_ci
611cb0ef41Sopenharmony_ci```bash
621cb0ef41Sopenharmony_cinpm view express contributors.email
631cb0ef41Sopenharmony_ci```
641cb0ef41Sopenharmony_ci
651cb0ef41Sopenharmony_ciYou may also use numeric indices in square braces to specifically select
661cb0ef41Sopenharmony_cian item in an array field. To just get the email address of the first
671cb0ef41Sopenharmony_cicontributor in the list, you can run:
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_ci```bash
701cb0ef41Sopenharmony_cinpm view express contributors[0].email
711cb0ef41Sopenharmony_ci```
721cb0ef41Sopenharmony_ci
731cb0ef41Sopenharmony_ciIf the field value you are querying for is a property of an object, you should run:
741cb0ef41Sopenharmony_ci
751cb0ef41Sopenharmony_ci```bash
761cb0ef41Sopenharmony_cinpm view express time'[4.8.0]'
771cb0ef41Sopenharmony_ci```
781cb0ef41Sopenharmony_ci
791cb0ef41Sopenharmony_ciMultiple fields may be specified, and will be printed one after another.
801cb0ef41Sopenharmony_ciFor example, to get all the contributor names and email addresses, you
811cb0ef41Sopenharmony_cican do this:
821cb0ef41Sopenharmony_ci
831cb0ef41Sopenharmony_ci```bash
841cb0ef41Sopenharmony_cinpm view express contributors.name contributors.email
851cb0ef41Sopenharmony_ci```
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci"Person" fields are shown as a string if they would be shown as an
881cb0ef41Sopenharmony_ciobject.  So, for example, this will show the list of `npm` contributors in
891cb0ef41Sopenharmony_cithe shortened string format.  (See [`package.json`](/configuring-npm/package-json) for more on this.)
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci```bash
921cb0ef41Sopenharmony_cinpm view npm contributors
931cb0ef41Sopenharmony_ci```
941cb0ef41Sopenharmony_ci
951cb0ef41Sopenharmony_ciIf a version range is provided, then data will be printed for every
961cb0ef41Sopenharmony_cimatching version of the package.  This will show which version of `jsdom`
971cb0ef41Sopenharmony_ciwas required by each matching version of `yui3`:
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci```bash
1001cb0ef41Sopenharmony_cinpm view yui3@'>0.5.4' dependencies.jsdom
1011cb0ef41Sopenharmony_ci```
1021cb0ef41Sopenharmony_ci
1031cb0ef41Sopenharmony_ciTo show the `connect` package version history, you can do
1041cb0ef41Sopenharmony_cithis:
1051cb0ef41Sopenharmony_ci
1061cb0ef41Sopenharmony_ci```bash
1071cb0ef41Sopenharmony_cinpm view connect versions
1081cb0ef41Sopenharmony_ci```
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ci### Configuration
1111cb0ef41Sopenharmony_ci
1121cb0ef41Sopenharmony_ci#### `json`
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci* Default: false
1151cb0ef41Sopenharmony_ci* Type: Boolean
1161cb0ef41Sopenharmony_ci
1171cb0ef41Sopenharmony_ciWhether or not to output JSON data, rather than the normal output.
1181cb0ef41Sopenharmony_ci
1191cb0ef41Sopenharmony_ci* In `npm pkg set` it enables parsing set values with JSON.parse() before
1201cb0ef41Sopenharmony_ci  saving them to your `package.json`.
1211cb0ef41Sopenharmony_ci
1221cb0ef41Sopenharmony_ciNot supported by all npm commands.
1231cb0ef41Sopenharmony_ci
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ci#### `workspace`
1271cb0ef41Sopenharmony_ci
1281cb0ef41Sopenharmony_ci* Default:
1291cb0ef41Sopenharmony_ci* Type: String (can be set multiple times)
1301cb0ef41Sopenharmony_ci
1311cb0ef41Sopenharmony_ciEnable running a command in the context of the configured workspaces of the
1321cb0ef41Sopenharmony_cicurrent project while filtering by running only the workspaces defined by
1331cb0ef41Sopenharmony_cithis configuration option.
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_ciValid values for the `workspace` config are either:
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci* Workspace names
1381cb0ef41Sopenharmony_ci* Path to a workspace directory
1391cb0ef41Sopenharmony_ci* Path to a parent workspace directory (will result in selecting all
1401cb0ef41Sopenharmony_ci  workspaces within that folder)
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ciWhen set for the `npm init` command, this may be set to the folder of a
1431cb0ef41Sopenharmony_ciworkspace which does not yet exist, to create the folder and set it up as a
1441cb0ef41Sopenharmony_cibrand new workspace within the project.
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci#### `workspaces`
1491cb0ef41Sopenharmony_ci
1501cb0ef41Sopenharmony_ci* Default: null
1511cb0ef41Sopenharmony_ci* Type: null or Boolean
1521cb0ef41Sopenharmony_ci
1531cb0ef41Sopenharmony_ciSet to true to run the command in the context of **all** configured
1541cb0ef41Sopenharmony_ciworkspaces.
1551cb0ef41Sopenharmony_ci
1561cb0ef41Sopenharmony_ciExplicitly setting this to false will cause commands like `install` to
1571cb0ef41Sopenharmony_ciignore workspaces altogether. When not set explicitly:
1581cb0ef41Sopenharmony_ci
1591cb0ef41Sopenharmony_ci- Commands that operate on the `node_modules` tree (install, update, etc.)
1601cb0ef41Sopenharmony_ciwill link workspaces into the `node_modules` folder. - Commands that do
1611cb0ef41Sopenharmony_ciother things (test, exec, publish, etc.) will operate on the root project,
1621cb0ef41Sopenharmony_ci_unless_ one or more workspaces are specified in the `workspace` config.
1631cb0ef41Sopenharmony_ci
1641cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci#### `include-workspace-root`
1671cb0ef41Sopenharmony_ci
1681cb0ef41Sopenharmony_ci* Default: false
1691cb0ef41Sopenharmony_ci* Type: Boolean
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ciInclude the workspace root when workspaces are enabled for a command.
1721cb0ef41Sopenharmony_ci
1731cb0ef41Sopenharmony_ciWhen false, specifying individual workspaces via the `workspace` config, or
1741cb0ef41Sopenharmony_ciall workspaces via the `workspaces` flag, will cause npm to operate only on
1751cb0ef41Sopenharmony_cithe specified workspaces, and not on the root project.
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_ciThis value is not exported to the environment for child processes.
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci### Output
1801cb0ef41Sopenharmony_ci
1811cb0ef41Sopenharmony_ciIf only a single string field for a single version is output, then it
1821cb0ef41Sopenharmony_ciwill not be colorized or quoted, to enable piping the output to
1831cb0ef41Sopenharmony_cianother command. If the field is an object, it will be output as a JavaScript object literal.
1841cb0ef41Sopenharmony_ci
1851cb0ef41Sopenharmony_ciIf the `--json` flag is given, the outputted fields will be JSON.
1861cb0ef41Sopenharmony_ci
1871cb0ef41Sopenharmony_ciIf the version range matches multiple versions then each printed value
1881cb0ef41Sopenharmony_ciwill be prefixed with the version it applies to.
1891cb0ef41Sopenharmony_ci
1901cb0ef41Sopenharmony_ciIf multiple fields are requested, then each of them is prefixed with
1911cb0ef41Sopenharmony_cithe field name.
1921cb0ef41Sopenharmony_ci
1931cb0ef41Sopenharmony_ci### See Also
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_ci* [package spec](/using-npm/package-spec)
1961cb0ef41Sopenharmony_ci* [npm search](/commands/npm-search)
1971cb0ef41Sopenharmony_ci* [npm registry](/using-npm/registry)
1981cb0ef41Sopenharmony_ci* [npm config](/commands/npm-config)
1991cb0ef41Sopenharmony_ci* [npmrc](/configuring-npm/npmrc)
2001cb0ef41Sopenharmony_ci* [npm docs](/commands/npm-docs)
201