Skip to content

Unable to target older node versions with node.js 17 #2534

@EmingK

Description

@EmingK
  • Node Version: 17.0.1
  • Platform: macOS Monterey 12.0.1
  • Compiler: Apple clang version 13.0.0 (clang-1300.0.29.3)
  • Module: The "hello world' demo addon in this project

Configure/build a project targeting older node.js versions under node.js v17 with node-gyp configure --target=<older node version> fails.

Verbose output (from npm or node-gyp):
❯ node-gyp configure --target=16.0.0 --verbose
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   '/usr/local/Cellar/node/17.0.1/bin/node',
gyp verb cli   '/usr/local/bin/node-gyp',
gyp verb cli   'configure',
gyp verb cli   '--target=16.0.0',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using node-gyp@8.3.0
gyp info using node@17.0.1 | darwin | x64
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - executable path is "/usr/local/opt/python@3.9/bin/python3.9"
gyp verb find Python - executing "/usr/local/opt/python@3.9/bin/python3.9" to get version
gyp verb find Python - version is "3.9.7"
gyp info find Python using Python version 3.9.7 found at "/usr/local/opt/python@3.9/bin/python3.9"
gyp verb get node dir compiling against --target node version: 16.0.0
gyp verb command install [ '16.0.0' ]
gyp verb install input version string "16.0.0"
gyp verb install installing version: 16.0.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: 16.0.0
gyp verb build dir attempting to create "build" dir: /Users/233/work/experiment/test-js/build
gyp verb build dir "build" dir needed to be created? Yes
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/233/work/experiment/test-js/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/233/work/experiment/test-js/config.gypi
gyp verb common.gypi checking for gypi file: /Users/233/work/experiment/test-js/common.gypi
gyp verb common.gypi found gypi file
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/local/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/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   '/Users/233/work/experiment/test-js/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/233/work/experiment/test-js/common.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/233/Library/Caches/node-gyp/16.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=/Users/233/Library/Caches/node-gyp/16.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/233/Library/Caches/node-gyp/16.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/233/work/experiment/test-js',
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   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' 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 (/usr/local/lib/node_modules/node-gyp/lib/configure.js:261:16)
gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 21.1.0
gyp ERR! command "/usr/local/Cellar/node/17.0.1/bin/node" "/usr/local/bin/node-gyp" "configure" "--target=16.0.0" "--verbose"
gyp ERR! cwd /Users/233/work/experiment/test-js
gyp ERR! node -v v17.0.1
gyp ERR! node-gyp -v v8.3.0
gyp ERR! not ok

It seems that node-gyp fetch config from the host node process (code). In node 17, the openssl_fips config item has been removed, causing corresponding config missing during gyp execution.

Considering the target node may be built with different configurations (for instance, Electron builds), shouldn't the build config fetched from target node platform instead of host process...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    OpenSSLRelated to https://www.openssl.orgmacOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions