1 ---
2 title: npm-view
3 section: 1
4 description: View registry info
5 github_repo: npm/cli
6 github_branch: latest
7 github_path: docs/lib/content/commands/npm-view.md
8 redirect_from:
9 - /cli-commands/npm-view
10 - /cli-commands/view
11 - /cli-documentation/cli-commands/npm-view
12 - /cli-documentation/cli-commands/view
13 - /cli-documentation/commands/npm-view
14 - /cli-documentation/commands/view
15 - /cli-documentation/npm-view
16 - /cli-documentation/v11/cli-commands/npm-view
17 - /cli-documentation/v11/cli-commands/view
18 - /cli-documentation/v11/commands/npm-view
19 - /cli-documentation/v11/commands/view
20 - /cli-documentation/v11/npm-view
21 - /cli-documentation/v11/view
22 - /cli-documentation/view
23 - /cli/cli-commands/npm-view
24 - /cli/cli-commands/view
25 - /cli/commands/npm-view
26 - /cli/commands/view
27 - /cli/npm-view
28 - /cli/v11/cli-commands/npm-view
29 - /cli/v11/cli-commands/view
30 - /cli/v11/commands/view
31 - /cli/v11/npm-view
32 - /cli/v11/view
33 - /cli/view
34 - /commands/npm-view
35 - /commands/view
36 ---
37
38 ### Synopsis
39
40 ```bash
41 npm view [<package-spec>] [<field>[.subfield]...]
42
43 aliases: info, show, v
44 ```
45
46 ### Description
47
48 This command shows data about a package and prints it to stdout.
49
50 As an example, to view information about the `connect` package from the registry, you would run:
51
52 ```bash
53 npm view connect
54 ```
55
56 The default version is `"latest"` if unspecified.
57
58 Field names can be specified after the package descriptor. For example, to show the dependencies of the `ronn` package at version `0.3.5`, you could do the following:
59
60 ```bash
61 npm view ronn@0.3.5 dependencies
62 ```
63
64 By default, `npm view` shows data about the current project context (by looking for a `package.json`). To show field data for the current project use a file path (i.e. `.`):
65
66 ```bash
67 npm view . dependencies
68 ```
69
70 You can view child fields by separating them with a period. To view the git repository URL for the latest version of `npm`, you would run the following command:
71
72 ```bash
73 npm view npm repository.url
74 ```
75
76 This makes it easy to view information about a dependency with a bit of shell scripting. For example, to view all the data about the version of `opts` that `ronn` depends on, you could write the following:
77
78 ```bash
79 npm view opts@$(npm view ronn dependencies.opts)
80 ```
81
82 For fields that are arrays, requesting a non-numeric field will return all of the values from the objects in the list. For example, to get all the contributor email addresses for the `express` package, you would run:
83
84 ```bash
85 npm view express contributors.email
86 ```
87
88 You may also use numeric indices in square braces to specifically select an item in an array field. To just get the email address of the first contributor in the list, you can run:
89
90 ```bash
91 npm view express contributors[0].email
92 ```
93
94 If the field value you are querying for is a property of an object, you should run:
95
96 ```bash
97 npm view express time'[4.8.0]'
98 ```
99
100 Note: When accessing object properties that contain special characters or numeric keys, you need to use quotes around the key name. For example, to get the publish time of a specific version:
101
102 ```bash
103 npm view express "time[4.17.1]"
104 ```
105
106 Without quotes, the shell may interpret the square brackets as glob patterns, causing the command to fail. You can also access the time field for a specific version by specifying the version in the package descriptor:
107
108 ```bash
109 npm view express@4.17.1 time
110 ```
111
112 This will return all version-time pairs, but the context will be for that specific version.
113
114 Multiple fields may be specified, and will be printed one after another. For example, to get all the contributor names and email addresses, you can do this:
115
116 ```bash
117 npm view express contributors.name contributors.email
118 ```
119
120 "Person" fields are shown as a string if they would be shown as an object. So, for example, this will show the list of `npm` contributors in the shortened string format. (See [`package.json`](/cli/v11/configuring-npm/package-json) for more on this.)
121
122 ```bash
123 npm view npm contributors
124 ```
125
126 If a version range is provided, then data will be printed for every matching version of the package. This will show which version of `jsdom` was required by each matching version of `yui3`:
127
128 ```bash
129 npm view yui3@'>0.5.4' dependencies.jsdom
130 ```
131
132 To show the `connect` package version history, you can do this:
133
134 ```bash
135 npm view connect versions
136 ```
137
138 ### Field Access Patterns
139
140 The `npm view` command supports different ways to access nested fields and array elements in package metadata. Understanding these patterns makes it easier to extract specific information.
141
142 #### Nested Object Fields
143
144 Use dot notation to access nested object fields:
145
146 ```bash
147 # Access nested properties
148 npm view npm repository.url
149 npm view express bugs.url
150 ```
151
152 #### Array Element Access
153
154 For arrays, use numeric indices in square brackets to access specific elements:
155
156 ```bash
157 # Get the first contributor's email
158 npm view express contributors[0].email
159
160 # Get the second maintainer's name
161 npm view express maintainers[1].name
162 ```
163
164 #### Object Property Access
165
166 For object properties (like accessing specific versions in the `time` field), use bracket notation with the property name in quotes:
167
168 ```bash
169 # Get publish time for a specific version
170 npm view express "time[4.17.1]"
171
172 # Get dist-tags
173 npm view express "dist-tags.latest"
174 ```
175
176 #### Extracting Fields from Arrays
177
178 Request a non-numeric field on an array to get all values from objects in the list:
179
180 ```bash
181 # Get all contributor emails
182 npm view express contributors.email
183
184 # Get all contributor names
185 npm view express contributors.name
186 ```
187
188 ### Configuration
189
190 #### `json`
191
192 - Default: false
193 - Type: Boolean
194
195 Whether or not to output JSON data, rather than the normal output.
196
197 - In `npm pkg set` it enables parsing set values with JSON.parse() before saving them to your `package.json`.
198
199 Not supported by all npm commands.
200
201 #### `workspace`
202
203 - Default:
204 - Type: String (can be set multiple times)
205
206 Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
207
208 Valid values for the `workspace` config are either:
209
210 - Workspace names
211 - Path to a workspace directory
212 - Path to a parent workspace directory (will result in selecting all workspaces within that folder)
213
214 When set for the `npm init` command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
215
216 This value is not exported to the environment for child processes.
217
218 #### `workspaces`
219
220 - Default: null
221 - Type: null or Boolean
222
223 Set to true to run the command in the context of **all** configured workspaces.
224
225 Explicitly setting this to false will cause commands like `install` to ignore workspaces altogether. When not set explicitly:
226
227 - Commands that operate on the `node_modules` tree (install, update, etc.) will link workspaces into the `node_modules` folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, _unless_ one or more workspaces are specified in the `workspace` config.
228
229 This value is not exported to the environment for child processes.
230
231 #### `include-workspace-root`
232
233 - Default: false
234 - Type: Boolean
235
236 Include the workspace root when workspaces are enabled for a command.
237
238 When false, specifying individual workspaces via the `workspace` config, or all workspaces via the `workspaces` flag, will cause npm to operate only on the specified workspaces, and not on the root project.
239
240 This value is not exported to the environment for child processes.
241
242 ### Output
243
244 If only a single string field for a single version is output, then it will not be colorized or quoted, to enable piping the output to another command. If the field is an object, it will be output as a JavaScript object literal.
245
246 If the `--json` flag is given, the outputted fields will be JSON.
247
248 If the version range matches multiple versions then each printed value will be prefixed with the version it applies to.
249
250 If multiple fields are requested, then each of them is prefixed with the field name.
251
252 ### See Also
253
254 - [package spec](/cli/v11/using-npm/package-spec)
255 - [npm search](/cli/v11/commands/npm-search)
256 - [npm registry](/cli/v11/using-npm/registry)
257 - [npm config](/cli/v11/commands/npm-config)
258 - [npmrc](/cli/v11/configuring-npm/npmrc)
259 - [npm docs](/cli/v11/commands/npm-docs)