yarn init — Yarn CLI reference
Initialize a package in the current directory
yarn init
Initialize a package in the current directory
This command creates a manifest and supporting project files in the current 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.
At the root of a project, a .node-version file is created with the major of the latest Node.js release (unless there’s one already), which makes Yarn install that Node.js and run every script of the project with it. The --node-version option writes another version or range instead (latest being the default), and --no-node-version doesn’t create the file.
When a template is provided, Yarn initializes the project, installs the template in a temporary context, and runs its binary from the new project.
Mark the new package as private
Configure the package as a workspace root
Package name to write to the manifest
Node.js version or range to write to .node-version (the latest major by default; --no-node-version to create no file)
Hidden legacy Yarn 1 compatibility flag
Hidden legacy Yarn 1 compatibility flag
Examples#
Create a new package in the local directory
Create a new private package in the local directory
Create a new package that accepts workspaces in the packages/ directory
Create a new package with a specific name
Create a new package using Node.js 24 rather than the latest release