"error MSB8020: The build tools for v141 (Platform Toolset = 'v141') cannot be found" when trying to install npm module scrypt - c++

I´m trying to install the npm module scrypt.
I know scrypt requires node-gyp, i installed it globally (several times). Also I know node-gyp requires python 2.7 and MS Build Tools. I installed the latest python 2.7 build and i installed MS Build Tools. I also tried with VS Community Edition 2017. I tried to repair and reinstall both.
I also installed npm package windows-build-tools (several times) globally successful.
But wenn i try npm i scrypt i got the following errors:
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5):
error MSB8020: The build tools for v141 (Platform Toolset = 'v141')
cannot be found. To build using the v141 build tools, please install
v141 bu ild tools. Alternatively, you may upgrade to the current
Visual Studio tools by selecting the Project menu or right-click the
solution, and then selecting "Retarget solution".
[c:\project\node_modules\scrypt\build\copied_files.vcxproj] C:\Program
Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(57,5):
error MSB8020: The build tools for v141 (Platform Toolset = 'v141')
cannot be found. To build using the v141 build tools, please install
v141 bu ild tools. Alternatively, you may upgrade to the current
Visual Studio tools by selecting the Project menu or right-click the
solution, and then selecting "Retarget solution".
[c:\project\node_modules\scrypt\build\scrypt_wrapper.vcxproj]
Any tips or suggestions?

After a few more hours, i found out there was an old installation of visual studio 2015. I had to uninstall it first. I have no clue, why not the newest instance of build tools was used.
After this, and downgrading Node to v8, scrypt could be installed and compiled again.

I guess what fixed it for smonkey, who uninstalled an older installation of Visual Studio, was that that uninstall process also removed that old MSBuild path from %PATH%.
Because for me, just removing that old MSBuild.exe from the path fixed it. node-gyp does not need MSBuild on the path, but it gets tripped up if there is one on the path that's too old for the build target.
So either delete your MSBuild path, or make sure it points to the latest version. Unless of course you wanted to uninstall Visual Studio anyway, but that is not an option for some.

Just had this issue. Removing (or unsetting) the VCTargetsPath system variable fixed it for me. I think it was created by a previous VS2015 install, but removing VS2015 did not remove the variable.
(Ken Pespisa already posted this in a comment, but I missed it on a previous visit to this page. I am adding it as an answer so people can find it more easily.)

Related

The build tools for v141 (Platform Toolset = 'v141') cannot be found

I am writing code to load c++ dll from electron. I have installed Visual Studio v141 tools but when running npm install I get the following error:
"The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 b
uild tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [D:\CodeLathe\ElectronPOC\Practice\dll\backup\ElectronCall
ingDll_NaN_CloutDriveTestLib\build\jsToCppBridge.vcxproj]"
I saw all the similar questions in stackoverflow but none of the answers worked for me. The same problem is not reproducible on my colleague's machine
Could you try setting npm config set msvs_version 2015 ?
This sets the build tools version to lower.

Visual Studio Platform 2015 Toolset ='v141' cannot be found

I'm trying to compile a project using OpenFrameworks (a library which uses C++) in Visual Studio. The build is set to Release and X64 and in the project properties I have set the Platform Toolset to Visual Studio 2015 (v140)
However every time I try to build the project I get the same error (amongst others)
Error MSB8020 The build tools for v141 (Platform Toolset = 'v141')
cannot be found. To build using the v141 build tools, please install
v141 build tools.
I know v141 is from the new version of MSVS 2017 but I do not want to upgrade to as the new version is not compatible with OpenFrameworks. I have tried rebuilding the project from scratch several times and have also looked into the VCXPROJ file and verified that everything is set to V140 - and it is. All very bizarre.
It seems that on build, something is setting a requirement for v141 but I cannot seem to find where this is coming from. Does anyone have an idea?
I had such an issue. The solution is: open menu "Project"->Properties->Configuration Properites->General - and choose platform toolset v140.
Had this same error trying to npm install after cloning a node based project. It had an npm dependency that required C++ source to be compiled.
I had already modified my VS2017 install to include Individual Components -> VC++ 2017 version 15.7 v14.14 latest v141 tools
but that didn't help.
I applied these commands in succession
npm install -g node-gyp
npm install --global --production windows-build-tools
The first had no effect but the second did the trick and the npm install command completed successfully after that.
This was addressed in the comments of one of the answers, but it worked for me. I had both v140 and v141 build tools installed, so when I had to use v140 build tools for something, I set the VCTargetsPath variable to the path of the v140 build tools. Deleting this variable in my environment variables ultimately fixed this issue for me.
For this error, and similar, for other platforms (e.g. VS2013) this problem typically occurs because you installed an older version of VS after you installed a later one. It's my observation that this will effect all of your Visual Studio C++ projects, and you will have to manually set them to target the specific toolset for the given version of VS you are trying to build the project under.
If anyone has the same issue..
Reason: When someone tries to open existing solution which created/build on latest VS version (VS2015 / 2017) and tried to open with backward / old version of VS instance. Then this error might occur.
Please try below steps.
Right click Project->Properties->Configuration Properties.
Set 'Target Platform Version' as Supported OS version, i.e. for 8.1 > Win7 & 10 Win10
Set 'Platform tool set' as installed visual studio version.
Re-Build & Enjoy :)
I had that v141 error when building from command-line but not inside visual studio:
The build tools for v141 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install v141 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
Turns out it was because I was calling the wrong vcvars so I was using the wrong version of msbuild.exe:
:: wrong (Visual Studio 2015)
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 >NUL
:: correct (Visual Studio 2017)
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvars64.bat" x64 >NUL
Not sure it's possible for this to be the error inside visual studio, but I hope this is helpful to some future searcher...

node-gyp and contextify - The builds tools for v140 (Platform Toolset = 'v140') cannot be found

I have a project that depends on d3 version 3.5.3 and that depends on contextify. When that's running through node-gyp it's blowing up. Generally I've been able to fix this by specifying the msvs_version=2015, but that didn't work. So, I performed the following:
Modified my installation of VS 2015 and installed everything, which would have then included Common Tools for Visual C++.
Executed npm install -g windows-build-tools.
Executed npm config set msvs_version 2015
Even with those steps I'm still getting this error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5):
error MSB8020: The builds tools for v140 (Platform T oolset = 'v140') cannot be found.
To build using the v140 build tools, either click the Project menu or right-click the solution,
and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.
The interesting part to me is that it's trying to find these tools in v110; I'm just not sure why.
I fixed this by executed npm install inside of the Visual Studio Developer Command Prompt.

MSbuild Error: The builds tools for v140 (Platform Toolset = 'v140') cannot be found

I have a solution which is consists of a large number of projects (C++ and C#). I upgraded the solution to VS2015, so the toolset version for most of them are now set to V140, but a small number of projects need to remain in V110 (third party libraries, etc). When I build the solution in Visual Studio 2015, it builds just fine, but when TeamFoundationServer tries to build it, it fails with the following error:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets (44): The builds tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v140 to build using the v140 build tools.
I tried to specify the VisualStudioVersion or the path to the right MSBuild version as build arguments, but it didn't work as the rest of the projects (the ones in V110) will be in trouble.
Any help would be very appreciated.
I had the same issue. Steps given in this Solution helped me solve my issue. Repeating the steps here for future reference.
If you're attempting to build a Win32 "Desktop" application, the easiest way to get the v140 Platform Toolset is via the Visual Studio Installer (please see the image, below, for an illustration of steps '3.' and '4.'):
Launch the "Visual Studio Installer" from your start menu.
Select "Modify" for the instance of Visual Studio 2017 you have
installed.
Under the "Summary" pane of the workload selector, click the
"Desktop development with C++" expander (if it is collapsed)
Check the "VC++ 2015.3 v140 toolset (x86,x64)" optional feature.
The builds tools for v140 that's the platform toolset for VS2015.
If you are using TFS2015, you must make sure the build environment on your build machine be the same as your local developer machine. You should install VS2015 on your build machine.
If you are using TFS2013 or TFS2012, most probably MSBuild 12.0 is called.You need to set the build templates to point to MS Build version 14.0. For the details, check: TFS 2013 building .NET 4.6 / C# 6.0
Jacob's answer worked for me but C++ build tools were under VS Build Tools 2017 while I had VS 2019 Installer on Windows 10 as at July, 2019.
You're trying to build using a different version of the build toolset that is either not installed on your system or that the project can't use. To change it to something that you have installed on your system, right click on the project in your Solution Explorer.
Go to Properties. Configuration Properties>General>Platform Toolset>(Change this to a toolset that is installed on your system).
Make sure you do this for the Debug and Release builds
For the folks who are trying to do the same with Visual Studio Build Tools 2022, you may find this under Optional when choosing Desktop development with C++ Workload. Also, I had to update below variables in Environment variables to point to the new location.
Path: replace previous path for BuildTools with C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin
VCTargetsPath: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170
VS140COMNTOOLS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\ PS: I didn't have to change the value. But this setting was needed for me to work.
If you are using Visual Studio 2022 Build Tools, then the following PowerShell script will fix it:
$VS_BTOOLS_EXE="vs_buildtools.exe"
$VS_BTOOLS_URI="https://aka.ms/vs/17/release/vs_buildtools.exe"
Invoke-WebRequest -Uri $VS_BTOOLS_URI -OutFile $VS_BTOOLS_EXE
Start-Process -FilePath ./vs_BuildTools.exe -ArgumentList `
"--add", "Microsoft.VisualStudio.Component.VC.140", `
"--quiet", "--norestart", "--force", "--wait" -Wait -PassThru
Useful when silent installation is needed as well.
Jacob's answer worked for me, but I had to click on the "Individual components" tab at the top for my Step 3.
image
This solution worked perfectly for me: https://social.msdn.microsoft.com/Forums/vstudio/en-US/e0b9c601-2ece-4dcc-bac3-23ed7dd6801a/the-builds-tools-for-v120-platform-toolset-v120-cannot-be-found?forum=vclanguage

NPM Install on Windows 7 issue, no Microsoft.CPP folder

I'm having troubles with npm install on Windows 7.
I'm using Visual Studio 2013 Express and I've also installed Microsoft Build Tools 2013.
I have the Path variable set and I've tried with the --msvs_version parameter in the npm install
It gives me the
error MSB4019: "C:\Program Files (x86)\MSBuild\12.0\Microsoft.Cpp.Default.props" not found
That folder doesn't exist on my computer, I only have
MSBuild\12.0
and
MSBuild\Microsoft
What do I miss to install?? I would be able to compile Node project without having to install the full version of VS, if possible, and honestly, I would be able to do it by installing the minimum required software.
Thank you!