重要提示: 此中文文档针对的是 Yarn 2 版本。
有关 1.x 版本的中文文档,请点击进入 yarn.bootcss.com。
Yarn
yarn addyarn binyarn cache cleanyarn config getyarn config setyarn configyarn constraints queryyarn constraints sourceyarn constraintsyarn dedupeyarn dlxyarn execyarn infoyarn inityarn installyarn linkyarn nodeyarn npm infoyarn npm loginyarn npm logoutyarn npm publishyarn npm tag addyarn npm tag listyarn npm tag removeyarn npm whoamiyarn packyarn patch-commityarn patchyarn 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 unplugyarn upyarn upgrade-interactiveyarn version applyyarn version checkyarn versionyarn whyyarn workspaceyarn workspaces focusyarn workspaces foreachyarn workspaces list

yarn init

Create a new package.

Usage

$> yarn init [-p,--private] [-w,--workspace] [-i,--install]

Examples

Create a new package in the local directory :

yarn init

Create a new private package in the local directory :

yarn init -p

Create a new package and store the Yarn release inside :

yarn init -i latest

Create a new private package and defines it as a workspace root :

yarn init -w

Details

This command will setup a new package in your local directory.

If the -p,--private or -w,--workspace options are set, the package will be private by default.

If the -w,--workspace option is set, the package will be configured to accept a set of workspaces in the packages/ directory.

If the -i,--install option is given a value, Yarn will first download it using yarn set version and only then forward the init call to the newly downloaded bundle. Without arguments, the downloaded bundle will be latest.

The initial settings of the manifest can be changed by using the initScope and initFields configuration values. Additionally, Yarn will generate an EditorConfig file whose rules can be altered via initEditorConfig, and will initialize a Git repository in the current directory.