After you configure your offline mirror, Yarn will automatically add new package tarballs to the mirror. 但是,它不会自动移除不再在 yarn.lock
中提到的压缩包。 For example, if you $ yarn remove
a dependency, the tarball will remain in the mirror, even if no other dependencies have it as a sub-dependency. 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.