Fixing: NPM / Node error on Windows: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I was using Visual Studio 2015 update 3 on Windows 10 x64 and was getting the error: “The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.”, when running some gulp tasks.

I fixed the problem by letting Visual Studio 2015 update 3 use the “current”(at the time of writing) node version (v6.5.0), that was  installed in “C:\Program Files\nodejs”.

Steps

  • Download the “current” (v6.5.0) Windows x64 version of node (NOT, I repeat, NOT the LTS version) at https://nodejs.org/en/
  • Install it
  • Open Visual Studio 2015 > Tools > Options… > Project and Solutions > External Web Tools > Add an entry “C:\Program Files\nodejs”
  • Move the entry to the top of the list and restart visual studio:

image

No the following steps might not be necessary, but in case the error persists:

  • Remove the node_modules folder
  • Open the solution and project (this will trigger an npm install)
  • Open the Package Manger Console
  • npm cache clean
  • npm dedupe
  • npm install

2 Comments

  1. Raisa222

    This problem can easily be fixed with Long Path tool
    Long Path tool can resolve error messages like: path too long, cannot delete file, too long path, destination path is too long, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *