Skip to content

msbuild error MSB4025 #1144

Closed
Closed

Description

@operator-bot

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

Activity

  1. bnoordhuis commented on Mar 14, 2017

    @bnoordhuis
    Member

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

  2. simonbuchan commented on Mar 29, 2017

    @simonbuchan

    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. refack commented on Mar 29, 2017

    @refack
    Contributor

    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

  4. madcampos commented on Apr 17, 2017

    @madcampos

    I'm still getting this error with Windows 10, node 7.8.0, npm 4.2.0 and node-gyp 3.6.0.
    Also, setting the msvc_version config to 2017 gets some python error.

  5. himadrinath commented on Apr 17, 2017

    @himadrinath

    @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: gyp failed with exit code: 1
    gyp 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 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-17T20_28_15_807Z-debug.log'`

  6. refack commented on Apr 17, 2017

    @refack
    Contributor

    @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

  7. refack commented on Apr 17, 2017

    @refack
    Contributor

    @himadrinath try and set GYP_MSVS_VERSION=2015 before you npm i
    (At the time of the release of 3.6.0 GYP did not know what 2017 was)

  8. himadrinath commented on Apr 17, 2017

    @himadrinath

    @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`

    1
    2

  9. refack commented on Apr 17, 2017

    @refack
    Contributor

    Everything seems file...
    Could you run

    cd /d C:\Users\himad\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\
    powershell.exe -ExecutionPolicy Unrestricted -Command "&{Add-Type -Path 'Find-VS2017.cs'; [VisualStudioConfiguration.Main]::Query(); }"

    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?

  10. himadrinath commented on Apr 17, 2017

    @himadrinath

    @refack

    `Exception calling "Query" with "0" argument(s): "Input string was not in a correct format."
    At line:1 char:36

    • ... -Path 'Find-VS2017.cs'; [VisualStudioConfiguration.Main]::Query(); }
    •                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
      • FullyQualifiedErrorId : FormatException`
  11. refack commented on Apr 17, 2017

    @refack
    Contributor

    Seems like you have a non "canonical" node-gyp. Do:

    cd /d C:\Users\himad\AppData\Roaming\npm\node_modules\npm
    npm rm node-gyp
    npm i node-gyp@3.6.0 --no-link
  12. himadrinath commented on Apr 17, 2017

    @himadrinath

    @refack

    `C:\Users\himad\AppData\Roaming\npm\node_modules\npm>npm rm node-gyp

    • balanced-match@0.4.2 node_modules\balanced-match
    • concat-map@0.0.1 node_modules\concat-map
    • brace-expansion@1.1.7 node_modules\brace-expansion
    • minimatch@3.0.3 node_modules\minimatch
    • nopt@3.0.6 node_modules\node-gyp\node_modules\nopt
    • node-gyp@3.6.0 node_modules\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`

  13. refack commented on Apr 17, 2017

    @refack
    Contributor

    That's it. Now try and npm i your testProject

  14. himadrinath commented on Apr 18, 2017

    @himadrinath

    @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

    response

    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

    • ... -Path 'Find-VS2017.cs'; [VisualStudioConfiguration.Main]::Query(); }
    •                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
      • FullyQualifiedErrorId : FormatException`
  15. 41 remaining items

  16. abdelrady commented on Dec 8, 2018

    @abdelrady

    @hengkx Check this comment
    #1144 (comment)

  17. hengkx commented on Dec 10, 2018

    @hengkx

    @hengkx Check this comment
    #1144 (comment)

    Tried no effect

  18. VavRe commented on Dec 28, 2018

    @VavRe

    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

  19. endnch commented on Dec 31, 2018

    @endnch

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

  20. lksriemer commented on Jan 2, 2019

    @lksriemer

    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.
  21. Noxillio commented on Jan 17, 2019

    @Noxillio

    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:

    ..\src\integer.cpp(370): warning C4804: '-': unsafe use of type 'bool' in operation [C:\Users\Noxillio\Documents\GitHub\yum\node_modules\integer\build\integer.vcxproj]
    C:\Users\Noxillio\.node-gyp\10.15.0\x64\node.lib : fatal error LNK1106: invalid file or disk full: cannot seek to 0x2262F2 [C:\Users\Noxillio\Documents\GitHub\yum\node_modules\integer\build\integer.vcxproj]
    gyp ERR! build error
    gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
    gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
    gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
    gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
    gyp ERR! System Windows_NT 10.0.17763
    gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
    gyp ERR! cwd C:\Users\Noxillio\Documents\GitHub\yum\node_modules\integer
    gyp ERR! node -v v10.15.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok
    

    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?

  22. Chrissie commented on Mar 15, 2019

    @Chrissie

    @Noxillio

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

  23. watchingon9 commented on Jun 17, 2019

    @watchingon9

    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 #1144 (comment), it get me works:

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

    Result:
    66666

  24. SabariCG commented on Aug 7, 2019

    @SabariCG

    node_modules\nan\nan.h(911)
    : error C2661: 'v8::Value::ToString': no overloaded function takes 0 arguments
    (compiling source file ..\src\leveldown_async.cc

  25. HarshKumar01 commented on Aug 17, 2019

    @HarshKumar01

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

    @Chrissie Thanks a lot. This worked for me. (I had VS2017 build tools installed)

  26. thargenediad commented on Aug 21, 2019

    @thargenediad

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

    note that this should be run in PowerShell with Administrator Privileges

  27. frlzjosh commented on May 22, 2020

    @frlzjosh

    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 #1144 (comment), it get me works:

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

    Result:
    66666

    This works like a charm! I was stubborn to keep on using npm install --global --production windows-build-tools --vs2017 and --vs2019 as I am using those Visual Studio versions, finally when I used the version suggested by the author --vs2015 everything began to work!

  28. cclauss commented on May 22, 2020

    @cclauss
    Contributor
  29. deleted a comment from alfredbaudisch on Aug 19, 2021
  30. locked as resolved and limited conversation to collaborators on Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions