重要提示: 此中文文档针对的是 Yarn 的最新版本。
有关 1.x 版本的中文文档,请点击进入 classic.yarnpkg.cn。
Yarn

yarn patch

Prepare a package for patching.

Usage

$> yarn patch <package>

Options

Definition
Description

-u,--update

Reapply local patches that already apply to this packages

--json

Format the output as an NDJSON stream

Details

This command will cause a package to be extracted in a temporary directory intended to be editable at will.

Once you're done with your changes, run yarn patch-commit -s <path> (with <path> being the temporary directory you received) to generate a patchfile and register it into your top-level manifest via the patch: protocol. Run yarn patch-commit -h for more details.

Calling the command when you already have a patch won't import it by default (in other words, the default behavior is to reset existing patches). However, adding the -u,--update flag will import any current patch.