nodejs / node-gyp

Node.js native addon build tool
MIT License
9.98k stars 1.8k forks source link

Electron with ffi-napi npm start fails with node-gyp error code #2543

Closed topheroes closed 2 years ago

topheroes commented 3 years ago

Created an app following these instructions https://www.electronforge.io/guides/framework-integration/react Added npm install ffi-napi

npm start fails on Preparing native dependencies with the error:

| Preparing native dependencies: 0 / 1gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp
× Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild 'C:\projects\gyp-bug-reproduce\node_modules\ffi-napi'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `gyp` failed with exit code: 1

Error: node-gyp failed to rebuild 'C:\projects\gyp-bug-reproduce\node_modules\ffi-napi'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `gyp` failed with exit code: 1

The example to reproduce is here https://github.com/topheroes/gyp-bug-reproduce

Please advise

cclauss commented 3 years ago

In the FULL error log is there a line that looks like gyp ERR! node-gyp -v vX.Y.Z? See #652

topheroes commented 3 years ago

@cclauss Thank you for your prompt reply

I don't see any error info in the full log:

> gyp-bug-reproduce@1.0.0 start
> electron-forge start

√ Checking your system
√ Locating Application
- Preparing native dependencies  electron-rebuild rebuilding with args: [Arguments] {
  '0': {
    buildPath: 'C:\\projects\\gyp-bug-reproduce',
    electronVersion: '15.3.0',
    arch: 'x64'
  }
} +0ms
  electron-rebuild rebuilding with args: C:\projects\gyp-bug-reproduce 15.3.0 x64 [] false https://www.electronjs.org/headers [ 'prod', 'optional' ] false +4ms
  electron-rebuild exploring C:\projects\gyp-bug-reproduce\node_modules\electron-squirrel-startup +2ms
  electron-rebuild exploring C:\projects\gyp-bug-reproduce\node_modules\ffi-napi +2ms
  electron-rebuild exploring C:\projects\gyp-bug-reproduce\node_modules\electron-squirrel-startup\node_modules\debug +1ms
  electron-rebuild exploring C:\projects\gyp-bug-reproduce\node_modules\react +2ms
  electron-rebuild exploring C:\projects\gyp-bug-reproduce\node_modules\react-dom +2ms
  electron-rebuild identified prod deps: Set(0) {
  'electron-squirrel-startup': true,
  'ffi-napi': true,
  debug: true,
  react: true,
  ms: true,
  'get-uv-event-loop-napi-h': true,
  'node-addon-api': true,
  'node-gyp-build': true,
  'ref-napi': true,
  'ref-struct-di': true,
  'react-dom': true,
  'loose-envify': true,
  'object-assign': true,
  scheduler: true
} +1ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules +3ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@babel +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@babel\core\node_modules +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@babel\generator\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@babel\helper-compilation-targets\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@babel\highlight\node_modules +21ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron +24ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron\get\node_modules +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\cli\node_modules +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\core\node_modules +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\core\node_modules\@malept +3ms
\ Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\installer-dmg\node_modules +21ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\installer-dmg\node_modules\@malept +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\installer-zip\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\installer-zip\node_modules\@malept +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\template-base\node_modules +17ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\template-base\node_modules\@malept +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@gar +10ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@malept +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@nodelib +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@npmcli +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@sindresorhus +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@szmarczak +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@tootallnate +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@types +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@vercel +22ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@webassemblyjs +4ms
| Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\@xtuc +28ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\ansi-escapes\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\are-we-there-yet\node_modules +10ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\babel-loader\node_modules +20ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\body-parser\node_modules +16ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\bonjour\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\cacheable-request\node_modules +22ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\cliui\node_modules +22ms
/ Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\compression\node_modules +23ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\concat-stream\node_modules +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\dir-glob\node_modules +51ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron\node_modules\@types +3ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-installer-common\node_modules +9ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-notarize\node_modules +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-osx-sign\node_modules +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-packager\node_modules +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\node_modules\@malept +3ms
- Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\node_modules\@sindresorhus +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\node_modules\@szmarczak +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-squirrel-startup\node_modules +23ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\electron-winstaller\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\encoding\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\esrecurse\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\execa\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\express\node_modules +4ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\figures\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\finalhandler\node_modules +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\flora-colossus\node_modules +9ms
\ Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\galactus\node_modules +17ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\get-package-info\node_modules +14ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\global-prefix\node_modules +17ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\got\node_modules +9ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\hpack.js\node_modules +17ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\html-minifier-terser\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\http-errors\node_modules +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\inquirer\node_modules +23ms
| Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\jest-worker\node_modules +42ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\load-json-file\node_modules +19ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\make-dir\node_modules +19ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\meow\node_modules +10ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\node-abi\node_modules +44ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\normalize-package-data\node_modules +15ms
/ Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\nugget\node_modules +12ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\ora\node_modules +21ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\p-retry\node_modules +16ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\path-type\node_modules +23ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\pkg-dir\node_modules +11ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\portfinder\node_modules +13ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\redent\node_modules +41ms
- Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\ref-struct-di\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\renderkid\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\request\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\rxjs\node_modules +17ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\send\node_modules +13ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\send\node_modules\debug\node_modules +3ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\serve-index\node_modules +8ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\string_decoder\node_modules +38ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\strip-outer\node_modules +9ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\temp\node_modules +10ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\terser\node_modules +5ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\terser-webpack-plugin\node_modules +6ms
\ Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\through2\node_modules +6ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\tmp-promise\node_modules +10ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\trim-repeated\node_modules +13ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\url\node_modules +22ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\username\node_modules +7ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\verror\node_modules +61ms
| Preparing native dependencies  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\webpack-dev-server\node_modules +25ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\wrap-ansi\node_modules +28ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\xtend\node_modules +18ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\yargs\node_modules +16ms
  electron-rebuild scanning: C:\projects\gyp-bug-reproduce\node_modules\yarn-or-npm\node_modules +15ms
  electron-rebuild scanning: C:\projects\node_modules +20ms
  electron-rebuild scanning: C:\projects\node_modules\@types +9ms
\ Preparing native dependencies: 0 / 1  electron-rebuild assuming is prebuildify powered: ffi-napi +0ms
  electron-rebuild Checking for prebuilds for "ffi-napi" +0ms
  electron-rebuild Could not locate "C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\prebuilds\win32-x64\electron.napi.node", "C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\prebuilds\win32-x64\node.napi.node", or "C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\prebuilds\win32-x64\electron.abi89.node" +1ms
  electron-rebuild rebuilding ffi-napi with args [
  'node',
  'node-gyp',
  'rebuild',
  '--runtime=electron',
  '--target=15.3.0',
  '--arch=x64',
  '--dist-url=https://www.electronjs.org/headers',
  '--build-from-source',
  '--verbose',
  '--msvs_version=16.0'
] +0ms
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb download using dist-url https://www.electronjs.org/headers
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
/ Preparing native dependencies: 0 / 1gyp verb find Python - "python3" is not in PATH or produced an error
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
- Preparing native dependencies: 0 / 1gyp verb find Python - executable path is "C:\Python310\python.exe"
gyp verb find Python - executing "C:\Python310\python.exe" to get version
gyp verb find Python - version is "3.10.0"
gyp info find Python using Python version 3.10.0 found at "C:\Python310\python.exe"
gyp verb get node dir compiling against --target node version: 15.3.0
gyp verb command install [ '15.3.0' ]
gyp verb download using dist-url https://www.electronjs.org/headers
gyp verb install input version string "15.3.0"
gyp verb install installing version: 15.3.0
gyp verb install --ensure was passed, so won't reinstall if already installed
\ Preparing native dependencies: 0 / 1gyp 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: 15.3.0
gyp verb build dir attempting to create "build" dir: C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\build
gyp verb build dir "build" dir needed to be created? Yes
gyp verb find VS msvs_version was set from command line or npm config
gyp verb find VS - looking for Visual Studio version 2019
gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
\ Preparing native dependencies: 0 / 1gyp verb find VS checking VS2019 (16.11.31729.503) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v142
gyp verb find VS - found Windows SDK: 10.0.19041.0
gyp info find VS using VS2019 (16.11.31729.503) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp info find VS run with --verbose for detailed information
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\config.gypi
gyp verb common.gypi checking for gypi file: C:\projects\gyp-bug-reproduce\node_modules\ffi-napi\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Python310\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\projects\\gyp-bug-reproduce\\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:\\projects\\gyp-bug-reproduce\\node_modules\\ffi-napi\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\projects\\gyp-bug-reproduce\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\user\\.electron-gyp\\15.3.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\\user\\.electron-gyp\\15.3.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\projects\\gyp-bug-reproduce\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\user\\\\.electron-gyp\\\\15.3.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\projects\\gyp-bug-reproduce\\node_modules\\ffi-napi',
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:\\projects\\gyp-bug-reproduce\\node_modules\\ffi-napi\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
/ Preparing native dependencies: 0 / 1gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp
× Preparing native dependencies: 0 / 1

An unhandled error has occurred inside Forge:
node-gyp failed to rebuild 'C:\projects\gyp-bug-reproduce\node_modules\ffi-napi'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `gyp` failed with exit code: 1

Error: node-gyp failed to rebuild 'C:\projects\gyp-bug-reproduce\node_modules\ffi-napi'.
For more information, rerun with the DEBUG environment variable set to "electron-rebuild".

Error: `gyp` failed with exit code: 1

    at NodeGyp.rebuildModule (C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\src\module-type\node-gyp.ts:120:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at ModuleRebuilder.rebuildNodeGypModule (C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\src\module-rebuilder.ts:93:5)
    at Rebuilder.rebuildModuleAt (C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\src\rebuild.ts:299:5)
    at Rebuilder.rebuild (C:\projects\gyp-bug-reproduce\node_modules\electron-rebuild\src\rebuild.ts:200:9)
    at C:\projects\gyp-bug-reproduce\node_modules\@electron-forge\core\src\util\rebuild.ts:32:5
richardlau commented 3 years ago
  electron-rebuild rebuilding ffi-napi with args [
  'node',
  'node-gyp',
  'rebuild',
  '--runtime=electron',
  '--target=15.3.0',
  '--arch=x64',
  '--dist-url=https://www.electronjs.org/headers',
  '--build-from-source',
  '--verbose',
  '--msvs_version=16.0'
] +0ms
...
/ Preparing native dependencies: 0 / 1gyp: name 'openssl_fips' is not defined while evaluating condition 'openssl_fips != ""' in binding.gyp while trying to load binding.gyp
× Preparing native dependencies: 0 / 1

This is probably https://github.com/nodejs/node-gyp/issues/2534.

topheroes commented 3 years ago

@richardlau Downgrading Node to 16.13.0 helped

noseratio commented 2 years ago

I just spent my day solving this. Eventually, here's what has worked for me (also on SO ):

2812848295 commented 2 years ago

我只是花了一天时间解决这个问题。最终,这对我有用(也在 SO 上):

  • node-gyp在本地安装最新的:
    npm install -d node-gyp@latest
  • 在 中binding.gyp,添加(在顶部):

    {
      "variables": {
          "openssl_fips" : "0" 
      },
    
      ...      
    }

添加了貌似没有结果

cclauss commented 2 years ago

https://github.com/nodejs/node-gyp/issues/2673#issuecomment-1196931379