修剪离线镜像

After you configure your offline mirror, Yarn will automatically add new package tarballs to the mirror. 但是,它不会自动移除不再在 yarn.lock 中提到的压缩包。 例如,如果您 $ yarn remove 一个依赖项,则该压缩包将保持在镜像中,即使没有其他依赖项将它作为子依赖。 This behavior can be desirable in a setting where many projects share the same mirror, but when that is not the case, you may want to have Yarn remove unnecessary tarballs.

To turn on automating pruning, set yarn-offline-mirror-pruning to true in your .yarnrc:

$ yarn config set yarn-offline-mirror-pruning true

Now, tarballs will be removed when appropriate. The end result is that package.json, node_modules, yarn.lock, and the offline mirror should all remain perfectly in sync whenever you change your project’s dependencies.