Pruning an offline Mirror
In the previous tutorial we showed you how to configure an offline mirror. Having configured the offline mirror, you can now set up a build system without connecting to network, it also automatically adds new package tarballs to the mirror. However, yarn will not remove tarballs that are no longer referenced in the yarn.lock file. For instance, running yarn remove on a dependency will remove the dependency but the tarball will remain in the mirror, even when you don't have any dependency that have it as a sub-dependency.
Although this behavior is desirable in a setting where you have many projects that share the same mirror, but this is not the case most times, usually you will want to remove all unnecessary tarballs.
If you want to enable automatic pruning, you will have to set yarn-offline-mirror-pruning to true in your .yarnrc:
yarn config set yarn-offline-mirror-pruning true
Then yarn watches your dependencies and removes tarballs as appropriate. The result of this is your package.json, node_modules, yarn.lock, and the offline mirror will all remain perfectly in sync whenever you change your projects dependencies.
A few tips and tricks
When working with the offline mirror, here are some tricks that can become handy.
Updating your package
You can follow these steps to ensure that you have a clean cache module:
- You should remove the package first. Then, you ensure that you have "yarn-offline-mirror-pruning" set to true in your .yarnrc file
- Next you will have to clear the yarn cache using "yarn cache clean" before adding the updated version of the package
- Add your package
The "yarn-offline-mirror-pruning" helps clean up any unlinked dependencies. Whenever you add the updated package, yarn will check the yarn cache first and then pull any missing dependencies from there. Doing this, prevents yarn from adding new tarball back with the updated package. You will want to ensure that the yarn cache is all clean before you do any adding for cache module.
Previous:
Configuring an offline Mirror
Next:
Creating a package
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework