node-gyp: msbuild error MSB4025

I’m using Windows 10, node 7.7.2, npm 4.1.2

I get this error when running node-gyp rebuild for after installing the binding module leveldown (My objective is to rebuild it for electron). The specific error is…

MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing.

I searched for this error but it seemed to be specific to visual studio projects and xml files. I don’t have a lot of context since I’m not usually a windows user. Somewhere I found that you can specific --msvs_version=2013, that did not work. But I tried with 2017 (because that’s the latest download) and I got the following error.

Traceback (most recent call last):
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1900, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2017'

If anyone has any idas I would be very grateful! -S

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 65 (26 by maintainers)

Commits related to this issue

Most upvoted comments

Except it uses the msbuild.exe on the path by default, so you need to either ensure the v14.0 msbuild in %PROGRAM_FILES(x86)%\MSBuild\v14.0\Bin is the one it finds, or install the v140 C++ toolchain in VS 2017. Ugh.

3.6.0 supports VS2017 You can install Build Tools for Visual Studio 2017, make sure to select C++ tools, Windows 10 SDK and MSBuild and your set.

This bug can be closed /cc @rvagg

Edit

for node-gyp@3.6.0 do not install any of the special SDKs (red) only any of the greens image P.S. you only need one, and best tested is 10393

I solved this error by running npm install --global --production windows-build-tools --vs2015 (note the --vs2015)

For my case, i just want to install bcrypt in angular 8 app, here is how is the story i finally get it work:

First, this is what the error I get: 111

It say can’t find python, then I try run this in administrator terminal:

npm install --global --production windows-build-tools
npm install node-gyp

Then i try install bcrypt, i get some header files missing: 22222

After google, i get my Windows 10 SDK via Visual Studio Installer 333

Then i try again install bcrypt, get another error “MSBUILD : error MSB4025: The project file could not be loaded. Root element is missing”, which lead me here: 4444

Finally, i run this command from https://github.com/nodejs/node-gyp/issues/1144#issuecomment-450620159, it get me works:

npm install --global --production windows-build-tools --vs2015
npm install node-gyp
npm install node-gyp -g

Result: 66666

@Noxillio

#1691 Is the same problem. For me the solution was to npm config delete msvs_version and npm config delete msvs_version -g

@refack i don’t know how to thank you. it’s been more then 5 to 7 days i was trying to solve it. this is my first time in node and first package i installed. thank you is not enough…

@himadrinath Ohh man, what a hard first time. I’ve seen like 100,000 package installs first time it’s so hard. If you are a bug magnet I want to hire you as QA 😜

@refack i don’t know how to thank you. it’s been more then 5 to 7 days i was trying to solve it. this is my first time in node and first package i installed. thank you is not enough…

So who really solved this problem and how? I’ve tried everything still this error.

VS 2017 isn’t supported yet (see WIP in #1130) but if you install 2015 and pass --msvs_version=2015, it should work.

As @MadOPcode already pointed out, KeyError: '2017' is present in 3.8.0. Quite sure this error did not occur in the past.

Windows 10, VS2017, Python2.7 installed.

I performed all suggested actions, including uninstalling all the Windows for UWP, x64 and x86, etc. toolkits.

Run of node-gyp configure --verbose in some directory: gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli '...\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'configure',
gyp verb cli '--verbose' ]
gyp info using node-gyp@3.8.0
gyp info using node@10.15.0 | win32 | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (...\npm\node_modules\node-gyp\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (...\npm\node_modules\node-gyp\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (...\npm\node_modules\node-gyp\node_modules\which\which.js:80:29)
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\which\which.js:89:16
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (...\npm\node_modules\node-gyp\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (...\npm\node_modules\node-gyp\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (...\npm\node_modules\node-gyp\node_modules\which\which.js:80:29)
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\which\which.js:89:16
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at ...\npm\node_modules\node-gyp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2
at getNotFoundError (...\\npm\\node_modules\\node-gyp\\node_modules\\which\\which.js:13:12)
at F (...\\npm\\node_modules\\node-gyp\\node_modules\\which\\which.js:68:19)\n at E (...\\npm\\node_modules\\node-gyp\\node_modules\\which\\which.js:80:29)
at ...\\npm\\node_modules\\node-gyp\\node_modules\\which\\which.js:89:16
at ...\\npm\\node_modules\\node-gyp\\node_modules\\isexe\\index.js:42:5
at ...\\npm\\node_modules\\node-gyp\\node_modules\\isexe\\windows.js:36:5
at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Python27\python.EXE
gyp verb check python version `C:\Python27\python.EXE -c "import sys; print "2.7.14
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.15.0
gyp verb command install [ '10.15.0' ]
gyp verb install input version string "10.15.0"
gyp verb install installing version: 10.15.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.15.0
gyp verb build dir attempting to create "build" dir: C:\WINDOWS\system32\build
gyp verb build dir "build" dir needed to be created? C:\WINDOWS\system32\build
gyp verb Not using VS2017: Could not use PowerShell to find VS2017

And goes on to complain that this directory actually is not a node project.