How to Reinstall all Yarn Modules

Yarn (Yet Another Resource Negotiator) allows you to manage dependencies for large number of products from just a single repository. In this tutorial you will learn how to reinstall all the yarn modules in very easy way.

Methods to reinstall al yarn modules

Method 1: Force yarn to reinstall the package

You can also force yarn to reinstall all the packages you have installed in your system. Below are the steps you have to follow for this task.

Step 1: Delete your node_modules directory. Use the below command for that.

For macOS or Linux

rm -rf node_modules

For Windows cmd

rd /s /q "node_modules"

Step 2: Clear the yarn cache

After deleting the node modules clear the cache using the below command.

yarn cache clean

Step 3: Run the yarn-install command

After cache clean run the the below command with –check-files flag. It allows you verify all the installed files in the node_modules is removed or not

yarn install --check-files

If the above steps doesn’t work then install the package by forcing it. Use the below command.

yarn add <your-package-name> --force

Method 2: Use the Upgrade command.

If the above method is still not working then you can use use the yarn upgrade command to install the package. Just use the below command.

yarn upgrade <your-package-name>

To update all the dependencies in the package.json use the year upgrade command.

yarn upgrade

Method 3: Delete node_modules and yark.lock

If the above methods doesn’t work then delete the node_modules directory and yarn.lock file and start reinstalling all the dependencies provided in package.json file.

Use the below command.

For macOs and Linux

rm -rf node_modules
rm -f package-lock.json
rm -f yarn.lock

Clear the cache

npm cache clean --force

Install the packages

yarn install


The yarn command allows you perform many operations like upgrading, installing packages. If you are unable to install the packages then the above methods will solve your issues.

Hi, I am CodeTheBest. Here you will learn the best coding tutorials on the latest technologies like a flutter, react js, python, Julia, and many more in a single place.


This Offer is Limited! Grab your Discount!
15000 ChatGPT Prompts
Offer Expires In: