npm-view.1 7.9 KB

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