yarn info <package> [<field>]

这个命令会拉取包的信息并返回为树格式,包不必安装到本地。

  1. { name: 'react',
  2. version: '15.4.0-rc.2',
  3. description: 'React is a JavaScript library for building user interfaces.',
  4. time: { modified: '2016-10-06T22:09:27.397Z', ... } ... }

这个命令默认的报告样式时单引号序列化的。 要输出有效的 JSON 行格式,使用标准的 —json 标志:

  1. yarn info react --json
  1. {"type":"inspect","data":{"name":"react","time":{...}}}
  2. {"type":"finished","data":417}
  1. yarn info vx.x.x
  2. version: '15.3.0',
  3. time: { modified: '2016-10-06T22:09:27.397Z', ... } ... }

如果提供了可选字段参数,那么只有树的那部分被返回。

  1. yarn info react description
  1. yarn info vx.x.x
  2. React is a JavaScript library for building user interfaces.

或检查可用的版本:

  1. yarn info v1.1.0
  2. [ '0.0.1',
  3. '0.0.2',
  4. '0.0.3',
  5. (等)
  1. yarn info react time
  1. { modified: '2016-10-06T22:09:27.397Z',
  2. yarn info react time --json
  3. {"type":"inspect","data":{"modified":"2016-10-06T22:09:27.397Z","created":...}}
  4. ...

请注意,默认情况下,yarn info 不返回 readme 字段(因为它通常很长)。要显式请求那个字段,使用第二个参数:

  1. yarn info vx.x.x
  2. ## react
  3. An npm package to get you immediate access to
  4. [React](https://facebook.github.io/react/).
  5. ...