Blog >

Website project with node packages hanging Visual Studio on open of solution

If you’re like me and using Visual Studio as part of a website project connected to TFS, you’re trying to use Grunt tasks on the back of node package manager (NPM), and Visual Studio is hanging – read on.

I discovered a problem that after installing all the NPM packages, I could not open the Visual Studio solution for this project again – Visual Studio would just hang, evidently trying to process all the node_modules folders, and probably having this issue because many of the nested node_modules cause the ultimate Windows file path to be too long and exceed the maximum length of 260 characters. I think it was largely because of the ‘imagemin’ module, which has many nested dependencies, but there may have been others modules with issues.

The fix

The fix is simply to mark the top level ‘node_modules’ folder as hidden (but no need to mark any of it’s children as hidden). This evidently results in Visual Studio not trying to scan the ‘node_modules’ folder with it’s super long ‘node_modules’ file paths, which had been preventing VS from hanging on solution open.

Incorrect error messages

It was hard to track down this solution as Visual Studio gives out a number of errors that send you on a wild goose chase trying to solve it, such as:

  • tf400889 – The following path contains more than the allowed 259 characters
  • Something to the effect of “Source Control – {folder name}: Cannot add the item. There already exists an item with the same name under source control that prevents this add operation from continuing. Please rename the item and try adding it again.”

If you use the fix above, you should be able to open your solution again.

I found this solution buried here, for Umbraco: http://issues.umbraco.org/issue/U4-6219 (reply by Sebastiaan Janssen on 13th Feb 2015).