重要提示: 此中文文档针对的是 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 login

Store new login info to access the npm registry.

Usage

$> yarn npm login

Examples

Login to the default registry :

yarn npm login

Login to the registry linked to the @my-scope registry :

yarn npm login --scope my-scope

Login to the publish registry for the current package :

yarn npm login --publish

Options

Definition
Description

-s,--scope #0

Login to the registry configured for a given scope

--publish

Login to the publish registry

Details

This command will ask you for your username, password, and 2FA One-Time-Password (when it applies). It will then modify your local configuration (in your home folder, never in the project itself) to reference the new tokens thus generated.

Adding the -s,--scope flag will cause the authentication to be done against whatever registry is configured for the associated scope (see also npmScopes).

Adding the --publish flag will cause the authentication to be done against the registry used when publishing the package (see also publishConfig.registry and npmPublishRegistry).