electron-react-boilerplate / electron-react-boilerplate

A Foundation for Scalable Cross-Platform Apps
https://electron-react-boilerplate.js.org/
MIT License
23.27k stars 3.87k forks source link

Unable to Install Native Mac modules on M1 Mac #3503

Open oaimtiaz opened 1 year ago

oaimtiaz commented 1 year ago

Prerequisites

Expected Behavior

When installing packages in release/app, npm i should install/rebuild the project.

Current Behavior

npm i Lists an error related to node-abi versions. This has been tried with numerous packages, including both native Mac modules, and general modules to try to debug the issue.

Steps to Reproduce

git clone --depth 1 --branch main https://github.com/electron-react-boilerplate/electron-react-boilerplate.git bp
cd bp
npm install
cd release/app
npm i node-mac-permissions
npm i

npm i node-mac-permissions

added 4 packages, and audited 5 packages in 4s

found 0 vulnerabilities (base) omarimtiaz@omars-MacBook-Pro app % npm i

electron-react-boilerplate@4.6.0 postinstall npm run rebuild && npm run link-modules

electron-react-boilerplate@4.6.0 rebuild node -r ts-node/register ../../.erb/scripts/electron-rebuild.js

✖ Rebuild Failed

An unhandled error occurred inside electron-rebuild Could not detect abi for version 25.0.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron

Error: Could not detect abi for version 25.0.1 and runtime electron. Updating "node-abi" might help solve this issue if it is a new release of electron at Object.getAbi (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/node-abi/index.js:39:9) at get ABI [as ABI] (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/rebuild.js:86:39) at PrebuildInstall.prebuiltModuleExists (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/module-type/prebuild-install.js:59:179) at ModuleRebuilder.prebuildInstallNativeModuleExists (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/module-rebuilder.js:68:37) at Rebuilder.rebuildModuleAt (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/rebuild.js:128:35) at async Rebuilder.rebuild (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/rebuild.js:112:17) at async /Users/omarimtiaz/Documents/GitHub/bp/node_modules/@electron/rebuild/lib/cli.js:158:9 Error: Command failed: ../../node_modules/.bin/electron-rebuild --force --types prod,dev,optional --module-dir . at checkExecSyncError (node:child_process:885:11) at execSync (node:child_process:957:15) at Object. (/Users/omarimtiaz/Documents/GitHub/bp/.erb/scripts/electron-rebuild.js:16:11) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module.m._compile (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/ts-node/src/index.ts:1618:23) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Object.require.extensions. [as .js] (/Users/omarimtiaz/Documents/GitHub/bp/node_modules/ts-node/src/index.ts:1621:12) at Module.load (node:internal/modules/cjs/loader:1117:32) at Function.Module._load (node:internal/modules/cjs/loader:958:12) { status: 255, signal: null, output: [ null, null, null ], pid: 75488, stdout: null, stderr: null } npm ERR! code 1 npm ERR! path /Users/omarimtiaz/Documents/GitHub/bp/release/app npm ERR! command failed npm ERR! command sh -c npm run rebuild && npm run link-modules

npm ERR! A complete log of this run can be found in: npm ERR! /Users/omarimtiaz/.npm/_logs/2023-07-02T20_04_30_035Z-debug-0.log

Possible Solution (Not obligatory)

Context

I am trying to build a native Mac app that can access a user's contacts, and thus need to request permission using the OS. The library for this is node-mac-contacts. This library works when run in Electron using other frameworks, but, when migrating to Electron React Boilerplate, this issue has stopped all progress.

Your Environment

vrk commented 1 year ago

@oaimtiaz I had the same issue, and what fixed it for me was to install the latest version of node-abi via npm install node-abi@3.45.0 - hope that works for you too 🙏