nodejs / node-gyp

Node.js native addon build tool
MIT License
9.92k stars 1.79k forks source link

Error in evaluating "build_v8_with_gn" on node-gyp v3.4.0 for Node target v10.x #1457

Closed kanikashah90 closed 5 years ago

kanikashah90 commented 6 years ago

I am trying to build a native module on Node version 6.12.3 with target set to Node version 10.x. But the node-gyp command error out message: gyp: name 'build_v8_with_gn' is not defined while evaluating condition 'build_v8_with_gn == "true"' in binding.gyp while trying to load binding.gyp

Here are the commands I am invoking:

node --version
v6.12.3

~/{nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --version
v3.4.0

~/{nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --target=v10.4.0 --release

gyp info it worked if it ends with ok
gyp verb cli [ '{nodeSourceCodeLocation}/bin/node',
gyp verb cli   '{nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--target=v10.4.0',
gyp verb cli   '--release']
gyp info using node-gyp@3.4.0
gyp info using node@6.12.3 | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /usr/local/bin/python2
gyp verb check python version `/usr/local/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.15\n"
gyp verb get node dir compiling against --target node version: 10.4.0
gyp verb command install [ '10.4.0' ]
gyp verb install input version string "10.4.0"
gyp verb install installing version: 10.4.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.4.0
gyp verb build dir attempting to create "build" dir: {sourceFolderOnMyLocalMachine}/build
gyp verb build dir "build" dir needed to be created? {sourceFolderOnMyLocalMachine}/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: {sourceFolderOnMyLocalMachine}/build/config.gypi
gyp verb config.gypi checking for gypi file: {sourceFolderOnMyLocalMachine}/buildconfig.gypi
gyp verb common.gypi checking for gypi file: {sourceFolderOnMyLocalMachine}/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/local/bin/python2
gyp info spawn args [ '{nodeSourceCodeLocation}/lib/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   'make',
gyp info spawn args   '-I',
gyp info spawn args   '{buildTargetLocaltionOnMyLocalMachine}/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '{nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '{$HOME}/.node-gyp/10.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={$HOME}/.node-gyp/10.4.0',
gyp info spawn args   '-Dnode_gyp_dir={nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir={sourceFolderOnMyLocalMachine}',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
**gyp: name 'build_v8_with_gn' is not defined while evaluating condition 'build_v8_with_gn == "true"' 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 ({nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)
gyp ERR! System Darwin 17.3.0
gyp ERR! command "{nodeSourceCodeLocation}/bin/node" "{nodeSourceCodeLocation}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--target=v10.4.0" "--release"
gyp ERR! cwd {sourceFolderOnMyLocalMachine}
gyp ERR! node -v v6.12.3
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

The same issue is seen here https://github.com/mafintosh/prebuildify/issues/10 and there are insights on how to reproduce it.

bnoordhuis commented 6 years ago

build_v8_with_gn is coming from Node.js v10's common.gypi. As a workaround you can pass --build_v8_with_gn=false to node-gyp or npm.

Does it also happen with node-gyp 3.6.0?

kanikashah90 commented 6 years ago

The workaround worked. Thanks :)

Yeah, it also happens with node-gyp 3.6.0