You may have had issues like me when trying to delete a directory/folder from your windows machine that contains deeply nested Node Modules. You try to delete the folder but you get this error: "Source Path Too Long".

The problem is that Windows path names are limited to 260 characters. I tried all kinds of different suggested commands in PowerShell (none of which worked for me) so this is how I do it.

1. Edit package.json

Remove all dependencies and devDependencies dependencies from package.json and save.


  "name": "my-project",
  "version": "1.0.0",
  "description": "my node project",
  "main": "index.js",
  "scripts": {},
  "author": "Craig McKenna",
  "license": "ISC",
  "dependencies": {},
  "devDependencies": {}

2. NPM Prune

From the command line navigate to the project folder and run npm-prune.

cd path-to/my-project


npm prune

Running npm-prune without a specified file and without any flags will remove all packages that are not explicitly listed in package.json.

Be patient here. If you have many dependencies this process may take a while.

3. Delete

Now that all of your projects node modules are removed you can delete the folder without incident.


Npm prune is potentially slow but nonetheless effective.