Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 2 KB

README.md

File metadata and controls

80 lines (55 loc) · 2 KB

Removing node_modules from any project or any directory on Windows

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.

Method 1: Using rimraf

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:

How to use:

npx rimraf --glob **/node_modules

Otherwise install RimRaf:

npm install -g rimraf
rimraf --glob node_modules

And in the project folder delete the node_modules folder with:

If you want to recursively delete:

rimraf --glob .\**\node_modules

Please 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_modules

For More

Method 2: Using GitBash

rm -r node_modules

Method 3: Using npkill

I think this was not mentioned before. but the best way to delete unwanted node_modules is to install an utility called npmkill.

How to use:

You can install as globally

npm i -g npkill

Then simply call it on a folder directly from your terminal

npkill

or alternatively, you can directly use it without installation by writing:

npx npkill

You will then be presented with a list of projects, and by hitting space bar you can delete their node_modules.

Method 4: Using remove-node-modules

How to use:

  1. Install the remove-node-modules globally
npm install -g remove-node-modules
  1. cd to root and remove-node-modules
  2. or remove-node-modules path/to/folder

Source