node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

Windows 10: The build tools for v120 (Platform Toolset = 'v120') cannot be found.

Open nerijusgood opened this issue 11 years ago • 66 comments

When installing package via NPM some module had dependency that fired node-gyp rebuild which spawns tons of errors:

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5): error MSB8020: The build t
ools for v120 (Platform Toolset = 'v120') cannot be found. To build using the v120 build tools, please install v120 bui
ld tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-cli
ck the solution, and then selecting "Retarget solution". [C:\Users\nerij\Projects\react-browserify-cli\node_modules\bro
wser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modul
es\utf-8-validate\build\validation.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:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "c:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\nerij\Projects\react-browserify-cli\node_modules\browser-sync\node_modules\socket.io\node_modules\socket.io-client\node_modules\engine.io-client\node_modules\ws\node_modules\utf-8-validate
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]

This is part of install which gets errors. I fallowed instruction on node-gyp install, however Windows 10 does not allow instal Windows 7 SDKs (I found and installed Windows 10 SDKs, with no efefct). Anyone had same issues?

nerijusgood avatar Aug 02 '15 18:08 nerijusgood

Have you installed visual studio 2015 with visual C++? That helped for me.

perok avatar Aug 04 '15 21:08 perok

The above error is with MVS 2015 C++. Could not do anything here so I completely removed MVS 2015 and installed 2013 C++.

Now it seems to have different error. The error is with too long path names (opened case in stack overflow, since its not node-gyp fault): http://stackoverflow.com/questions/31817447/windows-10-node-gyp-cannot-build-msbuild-failed-with-exit-code-1

Any ideas?

nerijusgood avatar Aug 05 '15 08:08 nerijusgood

I have same problem in Windows 10 with VS2015&SDK. :-(

BlackGlory avatar Aug 08 '15 03:08 BlackGlory

If there were a +1 button, I'd be clicking it myself right now, but there's not, so I'm forced to pollute your issue with my comment. Please accept my humblest apologies. Windows 10 user. VS2015 and VS2013 both installed, and both with C++. utf-8-validate is the offender in my case too.

axefrog avatar Aug 14 '15 06:08 axefrog

I'm having problems with Windows 10. VS2015 community installed. I get the following error

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.   

musm avatar Aug 14 '15 16:08 musm

Guys, this worked for me; add GYP_MSVS_VERSION=2013 to your user environment variables. i.e. right-click start -> system -> advanced system settings -> environment variables -> "user variables for [username]" -> new Make sure you open a new console after doing this, so that the environment variable addition is picked up.

axefrog avatar Aug 14 '15 23:08 axefrog

@axefrog Thank you!!!!!!

With Windows 8.1 and VS2015 SDK/C++ installed I had to use:

GYP_MSVS_VERSION=2015

(so change the version to what you're using)

uxfed avatar Aug 16 '15 15:08 uxfed

BTW what SDK are people using? Im still using the one from the readme, if anyone gets this working on Windows 10 i would be ever so grateful if you could write a walkrthough, step by step guide. I've been struggling with this for the past few days now

@pjquinn I now get this error instead:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(214,5): error MSB4175: The task fac
tory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll". Cou
ld not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v12.0.dll' or one of its dependencies.
The system cannot find the file specified.

Can anyone help? :(

jasonwilliams avatar Aug 18 '15 20:08 jasonwilliams

Maybe try VS2015 w/ C++ and set env variable: GYP_MSVS_VERSION=2015

I'm on win 8.1 though, not 10

uxfed avatar Aug 18 '15 23:08 uxfed

@pjquinn that didn't work for me :-(

jasonwilliams avatar Aug 23 '15 21:08 jasonwilliams

@jayflux I also ended up installing beta npm@3 (using 3.3.0 currently), I'm not sure which of the above finally made it work, but it does now, at least on Win 8.1

uxfed avatar Aug 24 '15 00:08 uxfed

@pjquinn finally got it working by uninstalling Visual Studio 2015 and installing 2013, then i ran

set GYP_MSVS_VERSION=2013
npm install --msvs_version=2013

So 2013 deffo works on windows 10, not sure why 2015 fails

jasonwilliams avatar Aug 24 '15 19:08 jasonwilliams

@Jayflux what version of window, vs, and sdk are you using now?

zhaoyao91 avatar Aug 25 '15 08:08 zhaoyao91

@zhaoyao91 Windows 10 Visual Studio 2013 I have both SDK 7.1 and SDK 10 installed, I think its using 10 (any way for me to confirm this)? set GYP_MSVS_VERSION=2013 npm install --msvs_version=2013

jasonwilliams avatar Aug 26 '15 15:08 jasonwilliams

@Jayflux confirmed. Your method works. I completely removed all Microsoft associated build tools from Add/Remove Program panel. Then fresh clean install of VS2013 with no addons.

set GYP_MSVS_VERSION=2013
npm install --msvs_version=2013

It works. Tho, npm install --msvs_version=2013 dropped bunch of erros... I don't care - works.

nerijusgood avatar Aug 26 '15 18:08 nerijusgood

@Jayflux, thanks

Finally, it woks for me, all I need are: windows 10 64-bit node.js 0.12.x python 2.7.x vs 2013 (SDK and GYP_MSVS_VERSION are not needed)

and if both vs 2013 and vs 2015 are installed, set GYP_MSVS_VERSION=2013

I hope this will be helpful for others.

zhaoyao91 avatar Aug 27 '15 07:08 zhaoyao91

Why would you close this without either (a) adequate documentation or (b) at least a fix to look in both locations? That's lazy.

axefrog avatar Aug 27 '15 07:08 axefrog

Yeah this should not be closed. For one support for VS 2015 should be available. I shouldn't have to uninstall and reinstall VS to get this thing to build

musm avatar Aug 28 '15 14:08 musm

I managed to build with VS 2015 Community Edition under Windows 10. Turns out Microsoft decided to move the C-Runtime library to be part of the Operating System. I had to manually add the new locations of the header and library files to the file located at %HOMEPATH%.node-gyp\0.12.7\common.gypi.

(...)
    # Forcibly disable -Werror.  We support a wide range of compilers, it's
    # simply not feasible to squelch all warnings, never mind that the
    # libraries in deps/ are not under our control.
    'cflags!': ['-Werror'],
    'msvs_settings': {
      'VCCLCompilerTool': {
        'StringPooling': 'true', # pool string literals
        'DebugInformationFormat': 3, # Generate a PDB
        'WarningLevel': 3,
        'BufferSecurityCheck': 'true',
        'ExceptionHandling': 1, # /EHsc
        'SuppressStartupBanner': 'true',
        'WarnAsError': 'false',
        # ADDED
        'AdditionalIncludeDirectories': [ 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt' ],
      },
      'VCLibrarianTool': {
      },
      'VCLinkerTool': {
        'conditions': [
          ['target_arch=="ia32"', {
            'TargetMachine' : 1, # /MACHINE:X86
            # ADDED
            'AdditionalLibraryDirectories': [ 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x86' ],
            'target_conditions': [
              ['_type=="executable"', {
                'AdditionalOptions': [ '/SubSystem:Console,"5.01"' ],
              }],
            ],
          }],
          ['target_arch=="x64"', {
            'TargetMachine' : 17, # /MACHINE:AMD64
            # ADDED
            'AdditionalLibraryDirectories': [ 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x64' ],
            'target_conditions': [
              ['_type=="executable"', {
                'AdditionalOptions': [ '/SubSystem:Console,"5.02"' ],
              }],
            ],
          }],
        ],
        'GenerateDebugInformation': 'true',
        'RandomizedBaseAddress': 2, # enable ASLR
        'DataExecutionPrevention': 2, # enable DEP
        'AllowIsolation': 'true',
        'SuppressStartupBanner': 'true',
      },
    },
    'msvs_disabled_warnings': [4351, 4355, 4800],
(...)

I didn't check why VS doesn't find it's C-Runtime by itself and there may be a fancier solution for this. For example I have to manually maintain the paths. But I was able to build socket.io with all dependencies.

fresc81 avatar Sep 05 '15 15:09 fresc81

@fresc81 is this something you could put into a pull request? OR does there need to be some logic to check what OS you're on?

@all Whats the action needed here?

jasonwilliams avatar Sep 08 '15 11:09 jasonwilliams