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

Can't compile simple program on Windows with Node.js 22 #968

Closed
mureinik opened this issue May 2, 2024 · 1 comment · Fixed by nodejs/node#52794
Closed

Can't compile simple program on Windows with Node.js 22 #968

mureinik opened this issue May 2, 2024 · 1 comment · Fixed by nodejs/node#52794

Comments

@mureinik
Copy link

mureinik commented May 2, 2024

With nan 2.19, a barebones simple program fails to compile on Windows.

Attached is the full program (zipped). To test the failure:

  1. unzip nantest.zip
  2. Run npm install
  3. 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

> [email protected] install
> node-gyp rebuild

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.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.

Sample program:
nantest.zip

@kkoopa
Copy link
Collaborator

kkoopa commented May 2, 2024

nodejs/node#52794

Ch3nYuY pushed a commit to Ch3nYuY/node that referenced this issue May 8, 2024
V8 and Node.js had defined `NOMINMAX` on Windows for a long time.  In
recent changes, V8 added `std::numeric_limits::min` usages in its
header files which caused addons without `NOMINMAX` defines failed
to compile.

Define `NOMINMAX` in common.gypi so that addons can be compiled with
the latest V8 header files.

PR-URL: nodejs#52794
Fixes: nodejs/nan#968
Refs: nodejs/gyp-next#244
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
targos pushed a commit to nodejs/node that referenced this issue May 8, 2024
V8 and Node.js had defined `NOMINMAX` on Windows for a long time.  In
recent changes, V8 added `std::numeric_limits::min` usages in its
header files which caused addons without `NOMINMAX` defines failed
to compile.

Define `NOMINMAX` in common.gypi so that addons can be compiled with
the latest V8 header files.

PR-URL: #52794
Fixes: nodejs/nan#968
Refs: nodejs/gyp-next#244
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
EliphazBouye pushed a commit to EliphazBouye/node that referenced this issue Jun 20, 2024
V8 and Node.js had defined `NOMINMAX` on Windows for a long time.  In
recent changes, V8 added `std::numeric_limits::min` usages in its
header files which caused addons without `NOMINMAX` defines failed
to compile.

Define `NOMINMAX` in common.gypi so that addons can be compiled with
the latest V8 header files.

PR-URL: nodejs#52794
Fixes: nodejs/nan#968
Refs: nodejs/gyp-next#244
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
bmeck pushed a commit to bmeck/node that referenced this issue Jun 22, 2024
V8 and Node.js had defined `NOMINMAX` on Windows for a long time.  In
recent changes, V8 added `std::numeric_limits::min` usages in its
header files which caused addons without `NOMINMAX` defines failed
to compile.

Define `NOMINMAX` in common.gypi so that addons can be compiled with
the latest V8 header files.

PR-URL: nodejs#52794
Fixes: nodejs/nan#968
Refs: nodejs/gyp-next#244
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants