重要通知: 此文档针对的是 Yarn 1 (Classic) 版本。
对于 Yarn 2+ 文档及迁移指南,请访问 yarnpkg.cn。

yarn info

Show information about a package.

yarn info <package> [<field>]

This command will fetch information about a package and return it in a tree format. The package does not have to have been installed locally.

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', ... } ... }

The default reporting style for this command is a single-quoted serialization. To emit lines of valid JSON, use the standard --json flag:

yarn info react --json
{"type":"inspect","data":{"name":"react","time":{...}}}
{"type":"finished","data":417}

Information for a specific version

Append @[version] to the package argument to provide information specific to that 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', ... } ... }

Selecting specific fields

If the optional field argument is provided, then only that part of the tree is returned.

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

Or to check versions available:

yarn info react versions
yarn info v1.1.0
[ '0.0.1',
  '0.0.2',
  '0.0.3',
(etc)

If the specified field is in turn a nested object, the child tree is returned:

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":...}}
...

Retrieving the readme field

Note that by default, yarn info will not return the readme field (since it is often very long). To explicitly request that field, use the second argument:

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/).
...