Repository navigation
Closed
Description
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
Reacted by RyanQuey, Doug Ludlow, Patrick McDonough, Vincent, Siddharth Malik, Jaid, Rady Tantawy, 易容 (hyj1991), yogeshwar-paragyte, maqeelqureshi and 4 more
Metadata
Metadata
Assignees
Labels
No labels
Activity
bnoordhuis commentedon Mar 14, 2017
VS 2017 isn't supported yet (see WIP in #1130) but if you install 2015 and pass
--msvs_version=2015, it should work.Add support to build node.js with chakracore.
simonbuchan commentedon Mar 29, 2017
Except it uses the
msbuild.exeon the path by default, so you need to either ensure the v14.0 msbuild in%PROGRAM_FILES(x86)%\MSBuild\v14.0\Binis the one it finds, or install the v140 C++ toolchain in VS 2017. Ugh.refack commentedon Mar 29, 2017
3.6.0 supports VS2017
You can install
Build Tools for Visual Studio 2017, make sure to selectC++ tools,Windows 10 SDKandMSBuildand your set.This bug can be closed /cc @rvagg
Edit
for

node-gyp@3.6.0do not install any of the special SDKs (red) only any of the greensP.S. you only need one, and best tested is 10393
madcampos commentedon Apr 17, 2017
I'm still getting this error with
Windows 10, node7.8.0, npm4.2.0and node-gyp3.6.0.Also, setting the
msvc_versionconfig to2017gets some python error.himadrinath commentedon Apr 17, 2017
@refack after installing VS 2017 C++ Build Tools as u mention side by side with VS2017 community edition.
`> node-gyp rebuild
C:\Users\himad\Desktop\testProject\node_modules\sharp>if not defined npm_config_node_gyp (node "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Traceback (most recent call last):
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in
sys.exit(gyp.script_main())
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 545, in script_main
return main(sys.argv[1:])
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 538, in main
return gyp_main(args)
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 514, in gyp_main
options.duplicate_basename_check)
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp_init_.py", line 98, in Load
generator.CalculateVariables(default_variables, params)
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1918, in CalculateVariables
generator_flags.get('msvs_version', 'auto'))
File "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion
versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2017'
gyp ERR! configure error
gyp ERR! stack Error:
gypfailed with exit code: 1gyp ERR! stack at ChildProcess.onCpExit (C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:336:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:194:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\himad\Desktop\testProject\node_modules\sharp
gyp ERR! node -v v7.9.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
npm WARN testproject@1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.17.3 install:
node-gyp rebuildnpm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.17.3 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\himad\AppData\Roaming\npm-cache_logs\2017-04-17T20_28_15_807Z-debug.log'`
refack commentedon Apr 17, 2017
@himadrinath checking...
P.S. You don't have to install the Buildtools side by side, just make sure you have the three features installed in the "community edition" Instance
refack commentedon Apr 17, 2017
@himadrinath try and set
GYP_MSVS_VERSION=2015before younpm i(At the time of the release of 3.6.0
GYPdid not know what 2017 was)himadrinath commentedon Apr 17, 2017
@refack after set GYP_MSVS_VERSION=2015 getting this one
C:\Users\himad\Desktop\testProject\node_modules\sharp\build\libvips-cpp.vcxproj(20,3): error MSB4019: The imported proj ect "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and t hat the file exists on disk. gyp ERR! build error gyp ERR! stack Error:C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exefailed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:285:23) gyp ERR! stack at emitTwo (events.js:106:13) gyp ERR! stack at ChildProcess.emit (events.js:194:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12) gyp ERR! System Windows_NT 10.0.15063 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\himad\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\himad\Desktop\testProject\node_modules\sharp gyp ERR! node -v v7.9.0 gyp ERR! node-gyp -v v3.6.0 gyp ERR! not ok npm WARN testproject@1.0.0 No repository field. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sharp@0.17.3 install:node-gyp rebuild`npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.17.3 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sharp package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sharp
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sharp
npm ERR! There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\himad\AppData\Roaming\npm-cache_logs\2017-04-17T22_17_30_270Z-debug.log`
refack commentedon Apr 17, 2017
Everything seems file...
Could you run
You should see some JSON output similar to:
{"log":"Found installation at: D:\\bin\\dev\\VS\\2017\\BuildTools\n - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64\n - Found Microsoft.VisualStudio.Component.Windows10SDK.14393\n - Found Microsoft.VisualStudio.VC.MSBuild.Base\n - Using this installation with Windows 10 SDK","path":"D:\\bin\\dev\\VS\\2017\\BuildTools","sdk":"10.0.14393.0"}Could you post it?
himadrinath commentedon Apr 17, 2017
@refack
`Exception calling "Query" with "0" argument(s): "Input string was not in a correct format."
At line:1 char:36
refack commentedon Apr 17, 2017
Seems like you have a non "canonical" node-gyp. Do:
himadrinath commentedon Apr 17, 2017
@refack
`C:\Users\himad\AppData\Roaming\npm\node_modules\npm>npm rm node-gyp
C:\Users\himad\AppData\Roaming\npm\node_modules\npm>npm i node-gyp@3.6.0 --no-link
npm@4.5.0 C:\Users\himad\AppData\Roaming\npm\node_modules\npm
-- node-gyp@3.6.0 +-- minimatch@3.0.3 |-- brace-expansion@1.1.7| +-- balanced-match@0.4.2
|
-- concat-map@0.0.1-- nopt@3.0.6`refack commentedon Apr 17, 2017
That's it. Now try and
npm iyourtestProjecthimadrinath commentedon Apr 18, 2017
@refack after following the process as you told. one of my other machine i just installed VS 2017 C++ Build Tools and test it. its work fine
but still getting the same result into another machine where i just installed VS2017 Community
`Exception calling "Query" with "0" argument(s): "Input string was not in a correct format."
At line:1 char:36
41 remaining items
abdelrady commentedon Dec 8, 2018
@hengkx Check this comment
#1144 (comment)
hengkx commentedon Dec 10, 2018
Tried no effect
VavRe commentedon Dec 28, 2018
I literally tested everything above , everything ! doesn't work and I had to uninstall node js and it's components completely, installed it again and now everything is working nice and smooth ! believe me I tried everything, that was the best solution for me
endnch commentedon Dec 31, 2018
I solved this error by running
npm install --global --production windows-build-tools --vs2015(note the--vs2015)lksriemer commentedon Jan 2, 2019
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 okgyp 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.
Noxillio commentedon Jan 17, 2019
I am also getting
KeyError: '2017'About to try what @endnch suggested, will update when finished.
UPDATE: I get a different error when using 2015:
How is this problem still going on and why is it all of a sudden occurring when I've never had any trouble with this before?
Chrissie commentedon Mar 15, 2019
@Noxillio
#1691 Is the same problem. For me the solution was to
npm config delete msvs_versionandnpm config delete msvs_version -gwatchingon9 commentedon Jun 17, 2019
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:

It say can't find python, then I try run this in administrator terminal:
Then i try install bcrypt, i get some header files missing:

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

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:

Finally, i run this command from #1144 (comment), it get me works:
Result:

SabariCG commentedon Aug 7, 2019
node_modules\nan\nan.h(911)
: error C2661: 'v8::Value::ToString': no overloaded function takes 0 arguments
(compiling source file ..\src\leveldown_async.cc
HarshKumar01 commentedon Aug 17, 2019
@Chrissie Thanks a lot. This worked for me. (I had VS2017 build tools installed)
thargenediad commentedon Aug 21, 2019
note that this should be run in PowerShell with Administrator Privileges
frlzjosh commentedon May 22, 2020
This works like a charm! I was stubborn to keep on using
npm install --global --production windows-build-tools --vs2017and--vs2019as I am using those Visual Studio versions, finally when I used the version suggested by the author--vs2015everything began to work!cclauss commentedon May 22, 2020
https://www.npmjs.com/package/bcrypt is v4.0.1