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

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

Closed
EmingK opened this issue Oct 26, 2021 · 11 comments
Closed

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

EmingK opened this issue Oct 26, 2021 · 11 comments
Labels
macOS OpenSSL Related to https://www.openssl.org

Comments

@EmingK
Copy link

EmingK commented Oct 26, 2021

  • 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 [email protected]
gyp info using [email protected] | 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/[email protected]/bin/python3.9"
gyp verb find Python - executing "/usr/local/opt/[email protected]/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/[email protected]/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/[email protected]/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...?

@cclauss
Copy link
Contributor

cclauss commented Oct 26, 2021

Reaching way back but... #652

@nsfilho
Copy link

nsfilho commented Oct 29, 2021

@EmingK Hi! I'm facing the exactly same problem as you. Are you found any solution for this? I'm updated to Monterey too and Node.js 17.

@richardlau
Copy link
Member

richardlau commented Oct 29, 2021

This might be fixed by #2497 -- Node.js 17 no longer writes openssl_fips to config.gypi so it's not there in Node.js 17's process.config.

@jakobrosenberg
Copy link

#652 (comment)

@cclauss I'm not sure why I was redirected here. I'm not using Node 17. So far I've tried with Node 14 and 16.

If node-gyp issues related to electron-rebuild are out of scope, that's okay.

@cclauss
Copy link
Contributor

cclauss commented Nov 9, 2021

I'm not sure why I was redirected here.

You were directed here because you were commenting on an issue from 2015 and a lot has changed in the intervening six years. The error that you reported was name 'openssl_fips' is not defined and this issue discusses more recent instances of that error.

@DuBistKomisch
Copy link

DuBistKomisch commented Nov 23, 2021

I'm also seeing this error when targeting electron 11.2.3 from node 14.18.1, starting from node-gyp 8.4.0. It seems to be caused by this change a27dc08, since passing --force-process-config avoids it, but ironically I need that change to fix incorrect napi_build_version 🤦 .

Looking in ~/.cache/node-gyp/, they both define 'openssl_fips%': '' as a default, so not sure why it says it's undefined. The obviously difference is that node defines it (amongst about a hundred others) in include/node/config.gypi, while electron only defines 'build_with_electron': 1. Adding openssl_fips in manually just causes it to fail with napi_build_version undefined instead. Is this just an issue with Electron's config.gypi being wrong, since it wasn't used previously?

Tested quickly and yeah looks like this was fixed with Electron v14.2.0 with electron/electron#31404 which links back to this feature #2497... so that sucks, need to upgrade Electron by a few major versions.

@amac714
Copy link

amac714 commented Dec 20, 2021

upgrading electron-rebuild to v3.2.5 fixed this issue for us

@personjerry
Copy link

I found the temporary solution here: marktext/marktext#2812

Specifically, revert to node@16:

brew install node@16

Then add the paths to ~/.zshrc following the hints of brew, build it again.

@aminya
Copy link

aminya commented Apr 16, 2022

I'm also seeing this error when targeting electron 11.2.3 from node 14.18.1,

Seme here.
ericfreese/node-freetype2#46

@MasterOdin
Copy link

MasterOdin commented Jun 14, 2022

I found that upgrading to electron 13.6.9 also fixed the issue for me when I was trying to compile node-odbc. I think the version of node that's installed separate from electron is irrelevant when building for electron as it's using the bundled version of node when doing the build.

@cclauss cclauss added the OpenSSL Related to https://www.openssl.org label Jun 24, 2022
@cclauss
Copy link
Contributor

cclauss commented Jul 27, 2022

#2673 (comment)

@cclauss cclauss closed this as completed Jul 27, 2022
dhritzkiv added a commit to stackgl/angle that referenced this issue Oct 7, 2022
ewanharris added a commit to ewanharris/node-ios-device that referenced this issue Jan 11, 2023
cb1kenobi pushed a commit to tidev/node-ios-device that referenced this issue Jan 12, 2023
* Pass openssl_fips as a variable to support building older node versions on newer node versions

See nodejs/node-gyp#2534 and nodejs/node-gyp#2673
for more context on this issue

* Update dependencies

* Add support for Node.js 18 and 19

As node-pre-gyp is no longer maintained this is the path of least resistance to adding new versions,
we include a patch within this project that updates the abi_crosswalk file within node-pre-gyp that
is used to map the versions of node to their module/v8 versions. Then in run.js we call patch-package
before spawning anything to ensure that our patches are applied correctly.

This isn't by any means perfect but it's the quickest way to update the supported versions of node
without having to go and make any major refactors to the setup here, or the code in ioslib/the SDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS OpenSSL Related to https://www.openssl.org
Projects
None yet
Development

No branches or pull requests

10 participants