yarn info
显示一个包的信息。
yarn info <package> [<field>]
这个命令会拉取包的信息并返回为树格式,包不必安装到本地。
yarn info react
yarn info vx.x.x
{ name: 'react',
version: '15.4.0-rc.2',
description: 'React is a JavaScript library for building user interfaces.',
time: { modified: '2016-10-06T22:09:27.397Z', ... } ... }
这个命令默认的报告样式时单引号序列化的。 要输出有效的 JSON 行格式,使用标准的 --json
标志:
yarn info react --json
{"type":"inspect","data":{"name":"react","time":{...}}}
{"type":"finished","data":417}
指定版本的信息
追加 @[version]
到包名参数来提供那个特定版本的信息:
yarn info react@15.3.0
yarn info vx.x.x
{ name: 'react',
version: '15.3.0',
description: 'React is a JavaScript library for building user interfaces.',
time: { modified: '2016-10-06T22:09:27.397Z', ... } ... }
选择特定字段
如果提供了可选字段参数,那么只有树的那部分被返回。
yarn info react description
yarn info vx.x.x
React is a JavaScript library for building user interfaces.
或检查可用的版本:
yarn info react versions
yarn info v1.1.0
[ '0.0.1',
'0.0.2',
'0.0.3',
(etc)
如果指定的字段在一个内嵌的对象里,则返回子树:
yarn info react time
yarn info vx.x.x
{ modified: '2016-10-06T22:09:27.397Z',
created: '2011-10-26T17:46:21.942Z', ... }
yarn info react time --json
{"type":"inspect","data":{"modified":"2016-10-06T22:09:27.397Z","created":...}}
...
获取 readme 字段
请注意,默认情况下,yarn info
不返回 readme
字段(因为它通常很长)。要显式请求那个字段,使用第二个参数:
yarn info react readme
yarn info vx.x.x
## react
An npm package to get you immediate access to
[React](https://facebook.github.io/react/).
...