With nan 2.19, a barebones simple program fails to compile on Windows.
Attached is the full program (zipped). To test the failure:
unzip nantest.zip
Run npm install
If compilation is successful, you should get a native module with a function that returns 7, and a simple index.js file that calls it and asserts the result.
On Windows (with msvs 2022) and Node.js 22, the compilation fails with the following output:
Administrator@docker-win-03 MINGW64 ~/src/nantest
$ npm install
> nantest@1.0.0 install
> node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@10.1.0
gyp info using node@22.0.0 | win32 | x64
gyp info find Python using Python version 3.9.6 found at "C:\Program Files\Python39\python.exe"
gyp info find VS using VS2022 (17.9.34728.123) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Program Files\Python39\python.exe
gyp info spawn args [
gyp info spawn args 'C:\\Users\\Administrator\\AppData\\Roaming\\nvm\\v22.0.0\\node_modules\\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 '-I',
gyp info spawn args 'C:\\Users\\Administrator\\src\\nantest\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Administrator\\AppData\\Roaming\\nvm\\v22.0.0\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\Administrator\\AppData\\Local\\node-gyp\\Cache\\22.0.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\\Administrator\\AppData\\Local\\node-gyp\\Cache\\22.0.0',
gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\Administrator\\AppData\\Roaming\\nvm\\v22.0.0\\node_modules\\npm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\22.0.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\Users\\Administrator\\src\\nantest',
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 'C:\\Users\\Administrator\\src\\nantest\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args 'build\\binding.sln',
gyp info spawn args '/clp:Verbosity=minimal',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
native-seven.cpp
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): warning C4003: not enough arguments for function-like mac
ro invocation 'min' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): warning C4003: not enough arguments for function-like mac
ro invocation 'max' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): error C2589: '(': illegal token on right side of '::' [C:
\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): error C2760: syntax error: ')' was unexpected here; expec
ted 'expression' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): error C2760: syntax error: ')' was unexpected here; expec
ted ';' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): error C3878: syntax error: unexpected token ')' following
'expression_statement' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): message : error recovery skipped: ') <' [C:\Users\Adminis
trator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): message : error recovery skipped: ') ) ?' [C:\Users\Admin
istrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): message : error recovery skipped: ') :' [C:\Users\Adminis
trator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(408,62): message : error recovery skipped: ') ) ) . . . )' [C:\Us
ers\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): error C2589: '(': illegal token on right side of '::' [C:
\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): error C2760: syntax error: ')' was unexpected here; expec
ted 'expression' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): error C2760: syntax error: ')' was unexpected here; expec
ted ';' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): error C3878: syntax error: unexpected token ')' following
'expression_statement' [C:\Users\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): message : error recovery skipped: ') >' [C:\Users\Adminis
trator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): message : error recovery skipped: ') ) ?' [C:\Users\Admin
istrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): message : error recovery skipped: ') :' [C:\Users\Adminis
trator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
C:\Users\Administrator\AppData\Local\node-gyp\Cache\22.0.0\include\node\v8-function-callback.h(409,62): message : error recovery skipped: ') ) ) . . . )' [C:\Us
ers\Administrator\src\nantest\build\seven.vcxproj]
(compiling source file '../native-seven.cpp')
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\Administrator\AppData\Roaming\nvm\v22.0.0\node_modules\npm\node_modules\node-gyp\lib\build.js:209:23)
gyp ERR! stack at ChildProcess.emit (node:events:520:28)
gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe"
[nantest.zip](https://github.com/nodejs/nan/files/15186203/nantest.zip)
[nantest.zip](https://github.com/nodejs/nan/files/15186210/nantest.zip)
"C:\\Users\\Administrator\\AppData\\Roaming\\nvm\\v22.0.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\
node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Administrator\src\nantest
gyp ERR! node -v v22.0.0
gyp ERR! node-gyp -v v10.1.0
gyp ERR! not ok
npm ERR! code 1
npm ERR! path C:\Users\Administrator\src\nantest
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! A complete log of this run can be found in: C:\Users\Administrator\AppData\Local\npm-cache\_logs\2024-05-02T09_47_37_233Z-debug-0.log
The same program works fine on the same machine with Node.js 20, and on my MacOS laptop and Linux (Ubuntu) desktop with Node.js 22 or 20.
With nan 2.19, a barebones simple program fails to compile on Windows.
Attached is the full program (zipped). To test the failure:
npm install
7
, and a simpleindex.js
file that calls it and asserts the result.On Windows (with msvs 2022) and Node.js 22, the compilation fails with the following output:
The same program works fine on the same machine with Node.js 20, and on my MacOS laptop and Linux (Ubuntu) desktop with Node.js 22 or 20.
Sample program: nantest.zip