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):
rm -rf node_modules
You can use the npm package called rimraf to delete the node_modules directory:
npx 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:
find . -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:
npx npkill
You can use the arrow keys to select which node_modules folder you want to delete and delete them.
Top comments (1)
I am using windows 11 and due to some reason i am unable to delete node_modules from my angular and react projects i am just a beginner and i was learning them and now i want to delete those dummy projects i made, when i use "npx rimraf node_modules" it gives error -4094 and code "UNKNOWN" i have tried all methods listed on SO and even here but the error persists and i now have like 5-6 such projects which are of no use but i am unable to clear them off my memory pleasee helppp!!