Search code examples
node.jsvisual-studio-2013msbuildwindows-10node-gyp

Windows 10 node-gyp cannot build: MSBUILD failed with exit code 1


Windows 10, Microsoft Visual Studio 2013, Node v0.12.7, node-gyp v2.0.2

I always get the error build error with node-gyp:

Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1

Also in red color description:

Could not write lines to file "Release\obj\validation\validation.tlog\validation.lastbuildstate". 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. 

Bigger excerpt of error: https://gist.github.com/nerijusgood/63e54d9c376999a044bb

As I understand everything is running fine, however msbuild cannot write long path names. Is there a patch for this or windows workaround?


Solution

  • Edit: The question in title is a bit different from OP's actual issue (which this answer addresses).
    For node-gyp, or MSBUILD errors in general please see other questions.

    To solve the "The specified path, file name, or both are too long." issue, update npm to version 3+. This has been bothering all windows users for a while now, and the answer is to flatten your dependencies. npm@3.x automatically flattens all dependencies to the root even during install.