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:
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.
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: