If you're facing issues with removing deeply nested node_modules folders on Windows due to path length limitations, here are several methods to help you resolve the issue.
The rimraf package is a widely used solution to remove directories with long path names on any platform.
Update, if you have npm v5, use nxp:
npx rimraf --glob **/node_modulesOtherwise install RimRaf:
npm install -g rimrafrimraf --glob node_modulesAnd in the project folder delete the node_modules folder with:
If you want to recursively delete:
rimraf --glob .\**\node_modulesPlease save yourself the need to read most of these answers and just use npx rather than trying to install rimraf globally. You can run a single command and always have the most recent version with none of the issues seen here.
npx rimraf ./**/node_modulesrm -r node_modulesI think this was not mentioned before. but the best way to delete unwanted node_modules is to install an utility called npmkill.
You can install as globally
npm i -g npkillThen simply call it on a folder directly from your terminal
npkillor alternatively, you can directly use it without installation by writing:
npx npkillYou will then be presented with a list of projects, and by hitting space bar you can delete their node_modules.
- Install the
remove-node-modulesglobally
npm install -g remove-node-modules- cd to root and
remove-node-modules - or
remove-node-modules path/to/folder