Filepath too long?

I thought I'd write this post as a reminder to myself and as a helper for anyone daft enough to try to use Node on a Windows machine.

Node has a mental system for managing packages which involves deeply nesting dependencies in the node_modules folder. This can lead to all sorts of problems on Windows machines like making the --watch overload for Jekyll die on its ass.

You can't even delete the damn thing properly due to Windows path constraints. It's really annoying to say the least but at least they know about it

Here's a quick method I use to remove the folder when I need to.

Open a command prompt or whatever your shell tool of choice is, navigate to the parent folder of the node_modules folder and type in the following commands:

mkdir foo
robocopy foo node_modules /MIR
del foo
del node_modules

This command uses the robocopy utility and the /MIR "mirror" flag to mirror the empty foo directory to the node_modules folder emptying it out. You can then delete both directories.

Voilà :)

comments powered by Disqus