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

Error with trying to use VS2019 when building a Node Addon (with node-addon-api) #1962

Open
DragonOsman opened this issue Jun 7, 2019 · 5 comments
Labels
needs more info issues that need more info from the author Windows

Comments

@DragonOsman
Copy link

I have this error when I try to build an addon with node-addon-api:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [
gyp info spawn args   'C:\\Users\\Osman\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2019',
gyp info spawn args   '-I',
gyp info spawn args   'E:\\programming\\test-addon_medium\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Osman\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Osman\\.node-gyp\\12.4.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\Osman\\.node-gyp\\12.4.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\Osman\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\Osman\\.node-gyp\\12.4.0\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=E:\\programming\\test-addon_medium',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'E:\\programming\\test-addon_medium\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
  File "C:\Users\Osman\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\Users\Osman\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\Osman\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\Users\Osman\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "C:\Users\Osman\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Users\Osman\AppData\Roaming\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Users\Osman\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: '2019'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\Osman\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:200:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Osman\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--msvs_version=2019"
gyp ERR! cwd E:\programming\test-addon_medium
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok

The command I ran was: `node-gyp configure --msvs_version=2019". I did this on the Developer Command Prompt for VS 2019.

The version of Node I have is 12.4.0 and the version of Windows is Version 10.0.17763.503. Windows 10 Home, by the way.

Any help would be appreciated

@cjihrig cjihrig transferred this issue from nodejs/build Jun 7, 2019
@richardlau
Copy link
Member

VS2019 support (nodejs/node-gyp#1762) is on the list of things contained in the as yet unreleased [email protected]: nodejs/node-gyp#1723

@DragonOsman
Copy link
Author

Visual Studio 2017 gave me the same error, though? Maybe only VS2015 is fully supported so far.

@Danc2050
Copy link

Danc2050 commented Jan 4, 2022

Visual Studio 2017 gave me the same error, though? Maybe only VS2015 is fully supported so far.

2017 works for me as of today.

npm config set msvs_version 2017
npm install

@Asef00
Copy link

Asef00 commented Apr 28, 2022

Visual Studio 2017 gave me the same error, though? Maybe only VS2015 is fully supported so far.

2017 works for me as of today.

npm config set msvs_version 2017
npm install

In some cases, you need to set the correct path to MSBuild.exe

npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"

@RedYetiDev
Copy link
Member

@DragonOsman is this issue resolved?

@RedYetiDev RedYetiDev added the needs more info issues that need more info from the author label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info issues that need more info from the author Windows
Projects
None yet
Development

No branches or pull requests

5 participants