重要提示: 此中文文档针对的是 Yarn 的最新版本。
有关 1.x 版本的中文文档,请点击进入 classic.yarnpkg.cn。
Yarn
yarn addyarn binyarn cache cleanyarn config getyarn config setyarn config unsetyarn configyarn constraints queryyarn constraints sourceyarn constraintsyarn dedupeyarn dlxyarn execyarn explain peer-requirementsyarn explainyarn infoyarn inityarn installyarn linkyarn nodeyarn npm audityarn npm infoyarn npm loginyarn npm logoutyarn npm publishyarn npm tag addyarn npm tag listyarn npm tag removeyarn npm whoamiyarn packyarn patch-commityarn patchyarn plugin checkyarn plugin import from sourcesyarn plugin importyarn plugin listyarn plugin removeyarn plugin runtimeyarn rebuildyarn removeyarn runyarn searchyarn set resolutionyarn set version from sourcesyarn set versionyarn stageyarn unlinkyarn unplugyarn upyarn upgrade-interactiveyarn version applyyarn version checkyarn versionyarn whyyarn workspaceyarn workspaces focusyarn workspaces foreachyarn workspaces list

yarn npm info

Show information about a package.

Usage

$> yarn npm info ...

Examples

Show all available information about react (except the dist, readme, and users fields) :

yarn npm info react

Show all available information about react as valid JSON (including the dist, readme, and users fields) :

yarn npm info react --json

Show all available information about react@16.12.0 :

yarn npm info react@16.12.0

Show all available information about react@next :

yarn npm info react@next

Show the description of react :

yarn npm info react --fields description

Show all available versions of react :

yarn npm info react --fields versions

Show the readme of react :

yarn npm info react --fields readme

Show a few fields of react :

yarn npm info react --fields homepage,repository

Options

Definition
Description

-f,--fields #0

A comma-separated list of manifest fields that should be displayed

--json

Format the output as an NDJSON stream

Details

This command fetches information about a package from the npm registry and prints it in a tree format.

The package does not have to be installed locally, but needs to have been published (in particular, local changes will be ignored even for workspaces).

Append @<range> to the package argument to provide information specific to the latest version that satisfies the range or to the corresponding tagged version. If the range is invalid or if there is no version satisfying the range, the command will print a warning and fall back to the latest version.

If the -f,--fields option is set, it's a comma-separated list of fields which will be used to only display part of the package information.

By default, this command won't return the dist, readme, and users fields, since they are often very long. To explicitly request those fields, explicitly list them with the --fields flag or request the output in JSON mode.