You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
sys.exit(gyp.script_main())
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
return main(sys.argv[1:])
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
return gyp_main(args)
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
options.duplicate_basename_check)
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 130, in Load
params['parallel'], params['root_targets'])
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 2783, in Load
variables, includes, depth, check, True)
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 399, in LoadTargetBuildFile
includes, True, check)
File "E:\NPM_PREFIX\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 251, in LoadOneBuildFile
None)
File "binding.gyp", line 23
'msvs-settings':
^
SyntaxError: invalid syntax
Verbose output (from npm or node-gyp):
Traceback (most recent call last):
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\gyp_main.py", line 16, in
sys.exit(gyp.script_main())
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
return main(sys.argv[1:])
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
return gyp_main(args)
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
options.duplicate_basename_check)
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 130, in Load
params['parallel'], params['root_targets'])
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 2783, in Load
variables, includes, depth, check, True)
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 425, in LoadTargetBuildFile
build_file_data, PHASE_EARLY, variables, build_file_path)
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 1293, in ProcessVariablesAndConditionsInDict
build_file, key)
File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 1303, in ProcessVariablesAndConditionsInDict
' for ' + key)
TypeError: Unknown type set for AdditionalOptions while trying to load binding.gyp
That's strange. None of the given solutions sets the standard in the sln file for the analysis. But it works for the build.
see .vcxproj file?
Node-gyp should be able to do this automatically, but it does not. CMake easily does it by using.
set(CMAKE_CXX_STANDARD 17)
If anyone need solution irrespective of node-gyp use can use cmake... You can do this using cmake-js node package.
It easily handle these kind of things. Here is a example for you:
Thanks! I need to transfer to cmake-js. Too many problems with node-gyp. It does not solve anything for me as I have to manually maintain compiler flags for all the platforms.
Ran into this issue myself. Setting it through "msbuild_settings" worked but I think doing it that way messes up the node.exe hooking stuff since the compiled module would not load in electron. It also changes some other flags as well since the module no longer built as a static binary.
@refack's original suggestion worked for me. That said, the "VCCLCompilerTool" option should probably be updated to allow setting "LanguageStandard" directly instead of adding it through an additional command line option.
In my case, the -std:c++17 didn't work with VS 2022 and MS Build. I had to use the CLCompile version mentioned above.
I was banging my head up against the wall trying to find out how to override the C++20 that node-gyp was putting into the vcxprj but never could locate the source.
This is all because NodeRT uses C++ CX to create the projections, and that is not compatible with C++ 20.
Activity
refack commentedon Feb 7, 2019
Add the following to your binding.gyp:
Akarinnnnn commentedon Feb 7, 2019
Failed
binding.gyp.txt
refack commentedon Feb 7, 2019
replace
[with{for'msvs_settings'and'VCCLCompilerTool'binding.gyp.txt
Akarinnnnn commentedon Feb 8, 2019
Verbose output (from npm or node-gyp):
Traceback (most recent call last): File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\gyp_main.py", line 16, in sys.exit(gyp.script_main()) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main return main(sys.argv[1:]) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main return gyp_main(args) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main options.duplicate_basename_check) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 130, in Load params['parallel'], params['root_targets']) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 2783, in Load variables, includes, depth, check, True) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 425, in LoadTargetBuildFile build_file_data, PHASE_EARLY, variables, build_file_path) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 1293, in ProcessVariablesAndConditionsInDict build_file, key) File "E:\NPM_PREFIX\node_modules\prebuild\node_modules\node-gyp\gyp\pylib\gyp\input.py", line 1303, in ProcessVariablesAndConditionsInDict ' for ' + key) TypeError: Unknown type set for AdditionalOptions while trying to load binding.gypbinding.gyp.txt
i had changed binding.gyp as you said, but it does not work
rvagg commentedon Jun 20, 2019
please try and use Refael's exact syntax:
note the placement of
{' and['sAtiqGauri commentedon Jul 6, 2019
@rvagg still not working
aminya commentedon Nov 1, 2020
This is a full working example for anyone who also has this problem:
{ "targets": [ { "target_name": "proj", "sources": [ "src/proj.cc" ], "include_dirs": [ "<!@(node -p \"require('node-addon-api').include\")" ], 'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ], "cflags": [ "-fno-exceptions" ], "cflags_cc": [ "-fno-exceptions", "-std=c++17" ], "conditions": [ ['OS=="mac"', { "xcode_settings": { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', "CLANG_CXX_LIBRARY": "libc++", "CLANG_CXX_LANGUAGE_STANDARD":"c++17", 'MACOSX_DEPLOYMENT_TARGET': '10.14' } }], ['OS=="win"', { "msvs_settings": { "VCCLCompilerTool": { "AdditionalOptions": [ "-std:c++17", ], }, }, }] ] } ] }mceIdo commentedon Jan 4, 2021
The solutions above didn't work for me - the only way I could get it to work was using
It thows off some warnings, but it configures the project as it should and compiles
Akarinnnnn commentedon Jan 5, 2021
Yes.
ClCompileMSBuild item controls how compiler treats source fileaminya commentedon Jan 6, 2021
That's strange. None of the given solutions sets the standard in the sln file for the analysis. But it works for the build.
Akarinnnnn commentedon Jan 6, 2021
see .vcxproj file?
AtiqGauri commentedon Jan 6, 2021
If anyone need solution irrespective of node-gyp use can use cmake... You can do this using cmake-js node package.
It easily handle these kind of things. Here is a example for you: https://www.github.com/AtiqGauri/Patternscape/tree/master/Patternscape_Native_Addon%2FCMakeLists.txt
aminya commentedon Jan 6, 2021
Node-gyp should be able to do this automatically, but it does not. CMake easily does it by using.
Thanks! I need to transfer to cmake-js. Too many problems with node-gyp. It does not solve anything for me as I have to manually maintain compiler flags for all the platforms.
ToadKing commentedon Jan 12, 2021
Ran into this issue myself. Setting it through
"msbuild_settings"worked but I think doing it that way messes up the node.exe hooking stuff since the compiled module would not load in electron. It also changes some other flags as well since the module no longer built as a static binary.@refack's original suggestion worked for me. That said, the
"VCCLCompilerTool"option should probably be updated to allow setting"LanguageStandard"directly instead of adding it through an additional command line option.julianmesa-gitkraken commentedon Oct 6, 2022
lirf233 commentedon Nov 9, 2023
nice, it works!!
DanielCaspers commentedon Sep 3, 2024
For those coming here trying to get C++ 20 working with node addons relying on either Node directly or a derivative (e.g. Electron), don't forget that on Windows you will need to specify
/Zc:__cplusplus. It took a while for me to discover this sharp windows specific edge...https://stackoverflow.com/questions/63057156/language-supported-in-visual-studio-for-c-cplusplus-is-showing-as-c98/63057345#63057345
Psychlist1972 commentedon Sep 6, 2024
In my case, the -std:c++17 didn't work with VS 2022 and MS Build. I had to use the CLCompile version mentioned above.
I was banging my head up against the wall trying to find out how to override the C++20 that node-gyp was putting into the vcxprj but never could locate the source.
This is all because NodeRT uses C++ CX to create the projections, and that is not compatible with C++ 20.
I still have this in the binding.gyp, but it is overridden by the msbuild settings above
Psychlist1972 commentedon Sep 6, 2024
In my case, node-gyp was adding both that and the
/std:c++20to the project file by default, with no obvious way to override.BFjacky commentedon Dec 6, 2024
Worked with this config !!