Important: This documentation covers Yarn 2. For the 1.x doc, check classic.yarnpkg.com.
Yarn
yarn addyarn binyarn cache cleanyarn config getyarn config setyarn configyarn constraints queryyarn constraints sourceyarn constraintsyarn dlxyarn inityarn installyarn linkyarn nodeyarn npm infoyarn npm loginyarn npm publishyarn npm whoamiyarn packyarn patch-commityarn patchyarn plugin importyarn plugin listyarn plugin runtimeyarn rebuildyarn removeyarn runyarn set resolutionyarn set version from sourcesyarn set versionyarn stageyarn unplugyarn upyarn upgrade-interactiveyarn version applyyarn version checkyarn versionyarn whyyarn workspaceyarn workspaces foreachyarn workspaces list

yarn init

Create a new package.

Usage

$> yarn init [-p,--private] [-w,--workspace] [-l,--latest] [-i,--install #0]

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.

If the -l,--latest option is set, --install latest will be assumed.

The following settings can be used in order to affect what the generated package.json will look like:

  • initLicense

  • initScope

  • initVersion