重要提示: 此中文文档针对的是 Yarn 2 版本。
有关 1.x 版本的中文文档,请点击进入 yarn.bootcss.com。
Yarn
yarn addyarn binyarn cache cleanyarn config getyarn config setyarn config unsetyarn configyarn constraints queryyarn constraints sourceyarn constraintsyarn dedupeyarn dlxyarn execyarn explain peer-requirementsyarn 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 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 unplug

Force the unpacking of a list of packages.

Usage

$> yarn unplug ...

Examples

Unplug the lodash dependency from the active workspace :

yarn unplug lodash

Unplug all instances of lodash referenced by any workspace :

yarn unplug lodash -A

Unplug all instances of lodash referenced by the active workspace and its dependencies :

yarn unplug lodash -R

Unplug all instances of lodash, anywhere :

yarn unplug lodash -AR

Unplug one specific version of lodash :

yarn unplug lodash@1.2.3

Unplug all packages with the @babel scope :

yarn unplug '@babel/*'

Unplug all packages (only for testing, not recommended) :

yarn unplug -R '*'

Options

Definition
Description

-A,--all

Unplug direct dependencies from the entire project

-R,--recursive

Unplug both direct and transitive dependencies

--json

Format the output as an NDJSON stream

Details

This command will add the selectors matching the specified patterns to the list of packages that must be unplugged when installed.

A package being unplugged means that instead of being referenced directly through its archive, it will be unpacked at install time in the directory configured via pnpUnpluggedFolder. Note that unpacking packages this way is generally not recommended because it'll make it harder to store your packages within the repository. However, it's a good approach to quickly and safely debug some packages, and can even sometimes be required depending on the context (for example when the package contains shellscripts).

Running the command will set a persistent flag inside your top-level package.json, in the dependenciesMeta field. As such, to undo its effects, you'll need to revert the changes made to the manifest and run yarn install to apply the modification.

By default, only direct dependencies from the current workspace are affected. If -A,--all is set, direct dependencies from the entire project are affected. Using the -R,--recursive flag will affect transitive dependencies as well as direct ones.

This command accepts glob patterns inside the scope and name components (not the range). Make sure to escape the patterns to prevent your own shell from trying to expand them.