Node npm windows file paths are too long to install packages Node npm windows file paths are too long to install packages windows windows

Node npm windows file paths are too long to install packages


The problem with deeply nested folders on Windows has been mostly solved starting with npm version 3.x.

According to npm:

.npm@3 makes the install "maximally flat" by hoisting everything it can to the top level node_modules. This means nesting only occurs on conflicts and as such, trees should never get very deep. As such, the windows path length limitation shouldn't be run into.

I have just installed npm 3.1.0 and tried it out on a package that was throwing the dreaded The specified path, file name, or both are too long error.

The problem went away.

You can get the latest npm builds from here : npm releases


Windows 8.1 and 10 have an option to increase the Win32 path limit:

  • Open Group Policy Editor (Press Windows+R and type gpedit.msc and hit Enter)
  • Navigate to the following directory: Local Computer Policy\Computer Configuration\Administrative Templates\System\Filesystem
  • Doubleclick on Enable Win32 long paths option and enable it.

enter image description here


This is a work around solution.

There are some node modules that flattens your dependencies for you.
Links are here:

What these modules are doing can be done manually as well. This is the only real solution exists as of now, i.e to have all your modules at a single level, requiring each other, instead of all having private copies of their dependencies nested deeply.