Best Practices to yarn remove package

In this article we will learn about best practices to yarn remove package.

Yarn ( Yet Another Resource Negotiator ) is a package manager just like NPM which helps us to install and manage dependencies in our projects.

To remove a package / dependency from our project we can take two approach:

Approach 1 : yarn remove package

To remove a package from a project the easy and simple way is we just have to run:

yarn remove [package name]

This command will remove the package from node_modules and also update the yarn.lock file.

Approach 2 : Deleting it Manually

If you remove it manually by deleting it from the package.json file and then run:

yarn install

This will reinstall the node_modules again without the deleted package.

However it will not update the yarn.lock file.

So to solve this issue, you have to first delete the package in your package.json file and then delete the yarn.lock file and after that run yarn install

This time it will reinstall all your node_modules and update the yarn.lock file too.

Conclusion : So you can see, the best practices would be approach 1 (yarn remove package name). It will delete and update all the file with just one command.

Related Topics:

How To Clear Cache In Npm?

💾 Recommended Articles