nwjs / nw-gyp

native addon build tool for node-webkit
MIT License
195 stars 50 forks source link

nw-gyp failed with node 19.0.1 #155

Open onemen opened 1 year ago

onemen commented 1 year ago

When I'm running node 19.0.1 on windows 11 (nw-gyp -v v3.6.6)

The command nw-gyp configure --release --target=0.70.1 --arch=x64 --python="c:/python2.7/python.exe" failed with error: gyp: Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp

same result when running nw-gyp rebuild.

When i run the same command with node 18.12.1 it work.

binding.gyp:

{
  "targets": [
    {
      "target_name": "cityhash",
      "sources": [ "binding.cc", "mozilla/cityhash/city.cpp" ]
    }
  ]
}

console output:

gyp info it worked if it ends with ok
gyp info using nw-gyp@3.6.6
gyp info using node@19.0.1 | win32 | x64
gyp info find VS using VS2022 (17.3.32929.385) found at:
gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\USER_NAME\\AppData\\Local\\pnpm\\global\\5\\.pnpm\\nw-gyp@3.6.6\\node_modules\\nw-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=auto',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\USER_NAME\\projects\\testing\\installer\\src\\cityhash\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\USER_NAME\\AppData\\Local\\pnpm\\global\\5\\.pnpm\\nw-gyp@3.6.6\\node_modules\\nw-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\USER_NAME\\.nw-gyp\\0.70.1\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\USER_NAME\\.nw-gyp\\0.70.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\USER_NAME\\AppData\\Local\\pnpm\\global\\5\\.pnpm\\nw-gyp@3.6.6\\node_modules\\nw-gyp',
gyp info spawn args   '-Dnode_lib_file="C:\\Users\\USER_NAME\\.nw-gyp\\0.70.1\\<(target_arch)\\node.lib"',
gyp info spawn args   '-Dnw_lib_file="C:\\Users\\USER_NAME\\.nw-gyp\\0.70.1\\<(target_arch)\\nw.lib"',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\USER_NAME\\projects\\testing\\installer\\src\\cityhash',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '-Dv13=1',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\USER_NAME\\projects\\testing\\installer\\src\\cityhash\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\USER_NAME\AppData\Local\pnpm\global\5\.pnpm\nw-gyp@3.6.6\node_modules\nw-gyp\lib\configure.js:367:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Windows_NT 10.0.22621
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\USER_NAME\\AppData\\Local\\pnpm\\global\\5\\node_modules\\nw-gyp\\bin\\nw-gyp.js" "configure" "--release" "--target=0.70.1" "--arch=x64" "--python=c:/python2.7/python.exe"
gyp ERR! cwd C:\Users\USER_NAME\projects\testing\installer\src\cityhash
gyp ERR! node -v v19.0.1
gyp ERR! nw-gyp -v v3.6.6
gyp ERR! not ok
secribeiro commented 1 year ago

node 19.0.0 has been changed to make process.config read only #43627 and nw-gyp uses process.config and change it to create config.gypi in lib/configure.js

You need to change lib/configure.js file, line 118 to clone process.config object var config = process.config || {} to var config = JSON.parse(JSON.stringify(process.config)) || {}

After that you can compile your module with nw-gyp

onemen commented 1 year ago

Thank you @secribeiro it work 👍

aldrienht commented 1 year ago

Hi @secribeiro @onemen , i tried to update lib/configure.js as suggested above but running yarn install reverted it and issue shows in console again.

onemen commented 1 year ago

Try node 20

aldrienht commented 1 year ago

Hi @onemen - currently using node v20.2.0 I post a question on StackOverflow - here

onemen commented 1 year ago

@aldrienht,

I am not using Yarn, so i can not test it, but try to modify lib/configure.js after yarn install

theredpea commented 9 months ago

Is this fixed by https://github.com/nwjs/nw-gyp/pull/160 ?