Skip to content
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

Breaks with VS2019 installed #1753

Closed
TanninOne opened this issue May 16, 2019 · 24 comments
Closed

Breaks with VS2019 installed #1753

TanninOne opened this issue May 16, 2019 · 24 comments

Comments

@TanninOne
Copy link

node-gyp version 4.0.0
I have vs2015, vs2017 and vs2019 installed, I need them for different projects so uninstalling one isn't really an option.

As far as I can tell, if I use msvs_version=2017, the autodetection now finds the setup for 2019 and then fails to construct the correct path for msbuild which is now at
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
instead of
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe
as node-gyp seems to expect.

Now I'm fine with running the proper 2017 or 2019 and overwriting the msbuild path, doesn't really matter to me, but I can't find how to configure either.
I can apparently overwrite the msbuild path with the command line "--msbuild_path" and thus use vs2019 but the same parameter set globally through "npm config" seems to have no effect.
Any hints?

@ilya-edrets
Copy link

Run into the same problem.

@jyxjjj
Copy link

jyxjjj commented May 23, 2019

Mark.
Me too.
Use "--msbuild_path" successfully & use "npm config" or "--msvs_version" failed.

@ghost
Copy link

ghost commented May 26, 2019

Running this command seems to fix the issue on my system:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

@lusius
Copy link

lusius commented May 31, 2019

Running this command seems to fix the issue on my system:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

Thank you so much! We've been pulling hair about this for a long time.

@jyxjjj
Copy link

jyxjjj commented May 31, 2019

运行此命令似乎解决了我的系统上的问题:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

No, This won't fix mine.
I can only "--msbuild_path" param at every command, and must be 2017 version.

@jyxjjj
Copy link

jyxjjj commented Jun 5, 2019

prefix=D:\Program Files\NodeJS
cache=D:\Program Files\NodeJS\npm_cache
msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe

Set the file "D:\Program Files\NodeJS\node_modules\npm\npmrc" fixed.

@Vultraz
Copy link

Vultraz commented Jun 8, 2019

Can confirm this setup works

msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2017"

(set with npm config)

Using npm config set msvs_version 2019 causes its own problems:

Traceback (most recent call last):
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\Users\\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\\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\\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\\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\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Users\\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: '2019'

@say25
Copy link

say25 commented Jun 10, 2019

@joaocgreis it seems like 360ddbd should have fixed this is it possible to get a new release cut?

@jyxjjj
Copy link

jyxjjj commented Jun 10, 2019

@joaocgreis it seems like 360ddbd should have fixed this is it possible to get a new release cut?

But, some projects cannot be built with 2019.

@joaocgreis
Copy link
Member

joaocgreis commented Jun 13, 2019

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
npm install --global node-gyp@latest
for /f "delims=" %P in ('npm prefix -g') do npm config set node_gyp "%P\node_modules\node-gyp\bin\node-gyp.js"

Powershell
npm install --global node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}


That is, install node-gyp globally and make the npm config variable node_gyp point to node-gyp.js.

How to undo this after node-gyp is integrated into npm
npm uninstall --global node-gyp
npm config delete node_gyp

@VideoBeam
Copy link

Thanks a million joaocgreis. I am using VS 2019, along with node v10.16.2 and npm V 6.9.0.
Your suggestion resolved gyp build issues with several npm installs, including:
'npm install onoff' and 'npm install serialport'.

@TonieMwega
Copy link

npm install --global windows-build-tools

@cclauss
Copy link
Contributor

cclauss commented Jan 7, 2020

npm install --global windows-build-tools

I believe that will currently install VS 2017 and Python 2.7.17 which might not be desired in this case.

@Pointotech
Copy link

node-gyp has to be the messiest NPM package in existence. I'm trying to write Javascript and suddenly I'm in Microsoft dependency hell. What?

@rvagg
Copy link
Member

rvagg commented Mar 17, 2020

@Pointotech then stop trying to use non-javascript packages that need to be compiled, that's why you're here and Windows is the most difficult platform to be doing this. Clean your dependency tree and keep your catharsis off our issue tracker.

@EdmundTheRadiance
Copy link

EdmundTheRadiance commented May 6, 2020

Changing node version to 10.5.0 resolve this problem.
See this

@jyxjjj
Copy link

jyxjjj commented May 6, 2020

Changing node version to 10.5.0 resolve this problem.
See this

Such a low version. I remember that there is a single 2017 complier installer, that means we need not to install the full 2017 and i have not met again this problem.
I think it is necessary to update python and vs version for Node/NPM.
Many things are out of service.

--And btw, this issue is closed. create or find a newer to metion this issue id.

@nikhilmittal444
Copy link

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 node_gyp point to node-gyp.js.

How to undo this after node-gyp is integrated into npm

Finally it worked!!!!
Can't explain the headache I've had for days now <3

@GuiKang0424
Copy link

Hello !I want to use tfjs-examples,but i have trouble!Please help me...
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.7.6 found at "D:\anaconda\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio installed in "G:\webDownload\straw_hat_fairy-tfjs-examples-master\tfjs-examples\iris-fitDataset\node_modules\deasync="
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.4.29709.97) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v142
gyp ERR! find VS - found Windows SDK: 10.0.18362.0
gyp ERR! find VS - msvs_version does not point to this installation
gyp ERR! find VS checking VS2017 (15.9.28307.1146) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v141
gyp ERR! find VS - found Windows SDK: 10.0.17763.0
gyp ERR! find VS - msvs_version does not point to this installation
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS valid versions for msvs_version:
gyp ERR! find VS - "2019"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - "2017"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https:/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1051:16)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd G:\webDownload\straw_hat_fairy-tfjs-examples-master\tfjs-examples\iris-fitDataset\node_modules\deasync
gyp ERR! node -v v14.2.0
gyp ERR! node-gyp -v v7.0.0

@cclauss cclauss added the Windows label Jun 8, 2020
@adamczykpiotr
Copy link

For me the solution was to uninstall node 12.x and install version 10.21 (11.x might also work)

@josteink
Copy link

josteink commented Dec 14, 2020

When installing Visual Studio 2017 C++ Build Tools v141 using Visual Studio Installer, I was able to make this build, even when running latest Visual Studio, with no additional configuration required.

image

@amcarthur
Copy link

@Pointotech then stop trying to use non-javascript packages that need to be compiled, that's why you're here and Windows is the most difficult platform to be doing this. Clean your dependency tree and keep your catharsis off our issue tracker.

Wow you are dense

@stewartbright
Copy link

stewartbright commented Apr 20, 2021

For anyone that has not yet (or cannot) updated node on build servers, something like this also seems to work around the issue until you can update node. Basically, you set the vc build environment using vcvarsall.bat from 2017 before running npm install.

$VcVarsall = (Get-ChildItem -Path "C:\Program Files (x86)\Microsoft Visual Studio\2017\**\vcvarsall.bat" -Recurse).FullName
cmd /c "`"$VcVarsall`" x64 && npm install"

@arbaaz
Copy link

arbaaz commented Jul 26, 2021

Installing MSVS v141 fixed it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests