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

How to hide the command line window, when started from an other batch (*.cmd or *.bat) file.

If you want to start a batch file from an other batch file you can use the start command.

If you want to hide the command line window, that will be displayed by default, use the /B parameter.

 

Example

Test1.bat contents:

start /B /wait Test2.bat

exit

 

When you execute Test1.bat on the command line, the Test2.bat will be executed without showing a window.

(The Test1.bat will wait until Test2.bat is finished, because the /wait argument is supplied.)

Press tab in a Windows command line console window to loop files in a folder.

When you use cmd.exe and change directory to lets say: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319" and want to loop through all the files in the folder, just press tab to forward loop all files, press shift tab to reverse the loop.

You can also start typing the first part of the filename and then press tab.

 

So if you want to find aspnet_regiis.exe, you can type aspnet and the press tab to start looping the files, starting with first file that starts with "aspnet" in this case: Aspnet.config.

 

Yes, yes, I know this is probably the oldest shortcut in the DOS / Windows book, but I keep on forgetting it Winking smile