node-mac-contacts
node-mac-contacts copied to clipboard
Adds install script for Electron compatibility
Without this, building an Electron app will fail
Hi @Helvio88 what are the next steps? Not hugely required right now since I can patch it in, but just curious
Have been using in an Electron app without this patch btw.
Have been using in an Electron app without this patch btw.
@KishanBagaria, Are you using Electron Builder? If so, what version?
Yep, been working fine with the latest over the past two years. What do you see?
@KishanBagaria this is the output when I try to build my Electron app (without the patched package.json):
webpack 5.72.1 compiled successfully in 6609 ms
• electron-builder version=22.14.13 os=20.6.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=release/builder-effective-config.yaml
• rebuilding native dependencies [email protected], [email protected] platform=darwin arch=x64
• install prebuilt binary name=better-sqlite3 version=7.5.3 platform=darwin arch=x64 napi=
• rebuilding native dependency name=node-mac-contacts version=1.5.0
⨯ cannot execute cause=exit status 1
errorOut=npm ERR! Missing script: "install"
npm ERR!
npm ERR! Did you mean this?
npm ERR! npm uninstall # Remove a package
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xxxxx.npm/_logs/2022-06-02T16_51_44_548Z-debug-0.log
command=/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run install
workingDir=/Users/xxxxx/Development/Projects/bluebubbles-server/node_modules/node-mac-contacts
npm ERR! Lifecycle script `dist` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: @bluebubbles/[email protected]
npm ERR! at location: /Users/xxxxx/Development/Projects/bluebubbles-server/packages/server
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I've been using yarn which may have different behavior. You could also try upgrading npm, node and electron-builder (atm I'm on node v16.15.0, electron-builder v23.0.6, yarn v3.)
I've been using yarn which may have different behavior. You could also try upgrading npm, node and electron-builder (atm I'm on node v16.15.0, electron-builder v23.0.6, yarn v3.)
I'm also using yarn, just yarn 1.22.4, however, I wouldn't think that's the issue, but possibly... I'm just hesitant to use yarn v2 or 3 because technically they aren't "stable", right?
Iirc yarn v1 worked too earlier then we moved to v2/v3.
node-mac-contacts is built on NAPI which doesn't require rebuilding. We've been rebuilding native deps by passing the -o flag, like electron-rebuild -o foo,better-sqlite3,bar
Ok, let me reconfigure electron build and see if I can bypass needing this. Thanks @KishanBagaria for the sample
Removing electron-builder install-app-deps as my postinstall script and replacing it with electron-rebuild -o better-sqlite3 seemed to fix the issue. Closing.
Edit 1: Never-mind, it didn't fix the issue as the issue seems to lie in using electron-builder to build my app.
Edit 2: Electron builder will automatically rebuild all native dependencies when build is called. The only way to disable rebuilding dependencies is set npmRebuild to false. But doing so will prevent other packages from being rebuilt. I can't find a way to specifically ignore certain packages. I looked into beforeBuild as a parameter, but the context that's given doesn't provide the package name being rebuilt. Just the electron and platform information.