npm-view
选择命令行版本:
See Details
目录
概要
¥Synopsis
npm view [<package-spec>] [<field>[.subfield]...]aliases: info, show, v
描述
¥Description
此命令显示有关包的数据并将其打印到标准输出。
¥This command shows data about a package and prints it to stdout.
例如,要从注册表中查看有关 connect
包的信息,你可以运行:
¥As an example, to view information about the connect
package from the registry, you would run:
npm view connect
如果未指定,则默认版本为 "latest"
。
¥The default version is "latest"
if unspecified.
可以在包描述符之后指定字段名称。例如,要显示 0.3.5
版本的 ronn
包的依赖,你可以执行以下操作:
¥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:
npm view ronn@0.3.5 dependencies
默认情况下,npm view
显示有关当前项目上下文的数据(通过查找 package.json
)。要显示当前项目的字段数据,请使用文件路径(即 .
):
¥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. .
):
npm view . dependencies
你可以通过用句点分隔子字段来查看子字段。要查看最新版本 npm
的 git 存储库 URL,你将运行以下命令:
¥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:
npm view npm repository.url
这使得使用一些 shell 脚本可以轻松查看有关依赖的信息。例如,要查看 ronn
所依赖的 opts
版本的所有数据,可以这样写:
¥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:
npm view opts@$(npm view ronn dependencies.opts)
对于数组字段,请求非数字字段将返回列表中对象的所有值。例如,要获取 express
包的所有贡献者电子邮件地址,你可以运行:
¥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:
npm view express contributors.email
你还可以在方括号中使用数字索引来专门选择数组字段中的项目。要获取列表中第一个贡献者的电子邮件地址,你可以运行:
¥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:
npm view express contributors[0].email
如果你要查询的字段值是对象的属性,你应该运行:
¥If the field value you are querying for is a property of an object, you should run:
npm view express time'[4.8.0]'
可以指定多个字段,并且将一个接一个地打印。例如,要获取所有贡献者名称和电子邮件地址,你可以这样做:
¥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:
npm view express contributors.name contributors.email
"人" 字段如果显示为对象,则显示为字符 串。因此,例如,这将以缩短的字符串格式显示 npm
贡献者的列表。(有关这方面的更多信息,请参见 package.json
。)
¥"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
for more on this.)
npm view npm contributors
如果提供了版本范围,则将为包的每个匹配版本打印数据。这将显示每个匹配的 yui3
版本需要哪个版本的 jsdom
:
¥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
:
npm view yui3@'>0.5.4' dependencies.jsdom
要显示 connect
包版本历史,你可以这样做:
¥To show the connect
package version history, you can do this:
npm view connect versions
配置
¥Configuration
json
-
默认值:false
¥Default: false
-
类型:布尔值
¥Type: Boolean
是否输出 JSON 数据,而不是正常输出。
¥Whether or not to output JSON data, rather than the normal output.
-
在
npm pkg set
中,它可以使用 JSON.parse() 解析集合值,然后再将它们保存到你的package.json
。¥In
npm pkg set
it enables parsing set values with JSON.parse() before saving them to yourpackage.json
.
并非所有 npm 命令都支持。
¥Not supported by all npm commands.