-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node-gyp is unable to find msbuild if VS2019 is installed. #1663
Comments
I've just hit this, too. For those who want a temporary workaround, hand-editing the file
to this:
then reran:
|
@zhulika could you maybe submit a PR for this? |
I'm a C/C++ programmer. I'm not confident enough with Javascript or node-gyp to be able to implement something that detects the version of VS that is installed and adjust the output accordingly. |
@zhulika @chrisrpatterson I wasn't comfortable touching Updated, here's how the story continued after upgrading to node-gyp 5. |
Path of VS2019's MSBuild.exe is different from VS2017's MSBuild.exe. This change supports its path. And improve error check for finding msbuild.exe, if it is not found, then throws error. Fixes: nodejs#1663
I have sent PR #1715. |
As a side note, if we open "Visual Studio cmd for vs2019" and run node-gyp from it, it will detect MSBUILD.exe correctly, but most of the created projects will require v14.1 toolset and default one shipped with vs 2019 is v14.2
|
With MSBuild being on the PATH (after running vcvars before compiling), my setup was able to find MSBuild correctly, however, I get the error as above. I ended up having to edit |
as a workaround yes. |
I've edited the |
This still appears to be a problem, and the older Visual Studio versions aren't available anymore as far as i can tell:( |
Older versions of VS are still available. Scroll down to Older Versions on this page (https://visualstudio.microsoft.com/downloads/), it leads to: https://visualstudio.microsoft.com/vs/older-downloads/ Or use Chocolatey, a package manager for Windows based on Nuget. Cheers, and hope this bug is resolved soon |
Being addressed in #1762. |
node-gyp v5.0.0 is out with Visual Studio 2019 support. It's not yet integrated into npm so it has to be installed manually. This should do it (only need to be run once): Windows Command Prompt
Powershell
That is, install node-gyp globally and make the npm config variable How to undo this after node-gyp is integrated into npmnpm uninstall --global node-gyp
npm config delete node_gyp
|
Apologies if I'm being stupid but I don't think that this works, either. I ran the script (from a batch file called
then tried to build a native addin on a machine that has VS2019:
Why is it trying to find MSBuild here:
when it should be looking here:
? Is there something else that I should have done (obvious to most but I'm new to this so probably not obvious to me)? |
I think that the problem was down to my PC. I had so many node-gyp installations plastered all over this PC and it seems that it was using a copy that it shouldn't have. I have eliminated all of the obsolete versions and it is now building OK with your script applied. Apologies for the false alawm. |
Hi, I ran the command "npm install --global node-gyp@latest", which installed v5.0.2, as recommanded So i guess I need to run I'm developing with VsCode, and if I run this command in the console, I get an error ... |
@jeromesubs that command is for a cmd shell, but you're probably getting a PowerShell terminal inside VSCode. Try this one:
|
this seems like a really weird solution but i was able to fix it by doing the following in an administrator powershell:
had this problem on fresh installs of VS 2019 on two different laptops and this has fixed them both. |
@paulgg that will cause you issues when uninstalling or updating Node.js, expect node-gyp to stop working in the future. Changing the installation under The correct solution for PowerShell is:
|
In my case, here's what helped. In a nutshell, this PowerShell 6 inliner:
|
My solution was running this command before
|
Using yarn instead of npm fixed this for me *shrug* |
2019-11-30T10_41_01_335Z-debug.log |
@zeeterv, try this. |
Kind of dumb and late... changing \Enterprise\ to \Community\ worked for me. Should be logic since I don't have VS Enterprise Edition :/ Posting this, since this thread helped me, but lost some time figuring out the problem. Sometimes, on this situations, you just go blind to to little details. |
I've set all of those values and the items are installed in the correct referenced path but it still doesn't work. my config is:
If I switch that to the 2019 version it also fails even though it is also installed. |
I've done everything i've seen on this thread but still doesn't work, it was working before i updated node to 13.7.0 and i installed VS2019 Professional, i don't know which of those 2 things broke it |
6.13.6 |
Not sure if this has been suggested before, if so apologies. It's not a fix, but will do the job From the terminal you can launch
|
Fourth point might be redundant. This worked for me, hope it works for you as well. |
Worst issue I've run into in a good while. |
for others who do not use VSC Enterprise (I have build tools only) - the my path is |
Still a problem in 2021. I wish there was a way to backport compatibility shims, so the ancient version of node-gyp in my dependencies would just work without futzing with the path vars. |
@ariccio if I remember correctly, I think that I ended unsetting anything in the NPM config and used Visual studio installer to add MS build tools v2017 to my system next to the existing v2019... |
Guys this is fixed 2 years ago, you just need to install latest node-gyp globally and set npm to use that, detailed in a cm above:
|
As a note to the above comment, it only worked for me when I also ran the following command:
@syohex Could future comments be blocked for this issue since the solutions are provided. |
Verbose output (from npm or node-gyp):
I have also tried to install VS2017 build tools on the machine in addition to VS 2019 and node-gyp still tries to find msbuild under the VS2019 install. The issue is due to VS2019 having a different location for msbuild form VS2017. It puts it under C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin instead of C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\15.0\Bin
The text was updated successfully, but these errors were encountered: