Table of Contents
Have you ever got weird errors from npm and were suggested to delete node_modules directory and run npm i
?
We will see different ways in which we can delete node_modules from your project.
Deleting a single node_modules folder
You can delete the node_modules folder inside a single project by navigating to that project in the command prompt and running the following command (use Powershell or Git Bash if you are using windows):
1rm -rf node_modules
You can use the npm package called rimraf to delete the node_modules directory:
1npx rimraf node_modules
Listing and deleting multiple node_modules folders
If you want to list all the projects with node_modules, then you can use the following command:
1find . -name "node_modules" -type d -prune | xargs du -chs
To select node_modules one by one and delete them you can use the npkill
npm package:
1npx npkill
You can use the arrow keys to select which node_modules folder you want to delete and delete them.
If you have liked article, stay in touch with me by following me on twitter.
Leave a Comment