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

Generate a tarball from the active workspace.

Usage

$> yarn pack [--install-if-needed] [-n,--dry-run] [--json] [-o,--out #0] [--filename #0]

Examples

Create an archive from the active workspace :

yarn pack

List the files that would be made part of the workspace's archive :

yarn pack --dry-run

Name and output the archive in a dedicated folder :

yarn pack --out /artifacts/%s-%v.tgz

Details

This command will turn the active workspace into a compressed archive suitable for publishing. The archive will by default be stored at the root of the workspace (package.tgz).

If the --install-if-needed flag is set Yarn will run a preliminary yarn install if the package contains build scripts.

If the -n,--dry-run flag is set the command will just print the file paths without actually generating the package archive.

If the --json flag is set the output will follow a JSON-stream output also known as NDJSON (https://github.com/ndjson/ndjson-spec).

If the -o,---out is set the archive will be created at the specified path. The %s and %v variables can be used within the path and will be respectively replaced by the package name and version.