[javascript] How to clear cache in Yarn?

I am doing some benchmark tests for Facebook's Yarn. For this, I need to clear my global Yarn cache.

Is there a command available for this? I have force-removed my ~/.yarn-cache folder, but this seems to be quite manual.

This question is related to javascript npm dependency-management yarnpkg

The answer is


In addition to the answer, $ yarn cache clean removes all libraries from cache. If you want to remove a specific lib's cache run $ yarn cache dir to get the right yarn cache directory path for your OS, then $ cd to that directory and remove the folder with the name + version of the lib you want to cleanup.


Also note that the cached directory is located in ~/.yarn-cache/:

yarn cache clean: cleans that directory

yarn cache list: shows the list of cached dependencies

yarn cache dir: prints out the path of your cached directory


Run yarn cache clean.


Run yarn help cache in your bash, and you will see:

Usage: yarn cache [ls|clean] [flags]

Options: -h, --help output usage information -V, --version output the version number --offline
--prefer-offline
--strict-semver
--json
--global-folder [path]
--modules-folder [path] rather than installing modules into the node_modules folder relative to the cwd, output them here
--packages-root [path] rather than storing modules into a global packages root, store them here
--mutex [type][:specifier] use a mutex to ensure only one yarn instance is executing

Visit http://yarnpkg.com/en/docs/cli/cache for documentation about this command.


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?

Examples related to dependency-management

What's the difference between implementation and compile in Gradle? How to install a specific version of package using Composer? How to clear cache in Yarn? Javascript require() function giving ReferenceError: require is not defined How to add local .jar file dependency to build.gradle file? How to clean old dependencies from maven repositories? Android Studio: Add jar as library? Dealing with "Xerces hell" in Java/Maven? How do I add a Maven dependency in Eclipse? Force re-download of release dependency using Maven

Examples related to yarnpkg

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app Module not found: Error: Can't resolve 'core-js/es6' Yarn: How to upgrade yarn version using terminal? Yarn install command error No such file or directory: 'install' How to install package from github repo in Yarn How Do I Uninstall Yarn How to clear cache in Yarn?