Error when adding electron plugin to capacitor project - (npx cap add @capacitor-community/electron)
See original GitHub issueDescribe the bug
After installing Electron npm i @capacitor-community/electron
, adding electron using npx cap add @capacitor-community/electron
, shows the following error:
npx cap add @capacitor-community/electron
ℹ Adding Electron platform: start 🚀
ℹ Adding Electron platform: extracting template
ℹ Adding Electron platform: copying capacitor config file
ℹ Adding Electron platform: setting up electron project
✖ Adding Electron platform:
node:internal/process/promises:265
triggerUncaughtException(err, true /* fromPromise */);
^
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "
> fsevents@2.3.2 install /Users/macsupport/Downloads/core/electron/node_modules/chokidar/node_modules/fsevents
> node-gyp rebuild
> node-addon-api@3.2.1 install /Users/macsupport/Downloads/core/electron/node_modules/electron-rebuild/node_modules/lzma-native/node_modules/node-addon-api
> node-gyp rebuild
> electron@14.2.9 postinstall /Users/macsupport/Downloads/core/electron/node_modules/electron
> node install.js
npm WARN package.json Vetcalculators@1.0.0 No README data
gyp: binding.gyp not found (cwd: /Users/macsupport/Downloads/core/electron/node_modules/chokidar/node_modules/fsevents) 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:520:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/macsupport/Downloads/core/electron/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
npm WARN optional dep failed, continuing fsevents@2.3.2
npm WARN deprecated dmg-license@1.0.11: Disk image license agreements are deprecated by Apple and will probably be removed in a future macOS release. Discussion at: https://github.com/argv-minus-one/dmg-license/issues/11
npm WARN engine smart-buffer@4.2.0: wanted: {"node":">= 6.0.0","npm":">= 3.0.0"} (current: {"node":"16.14.0","npm":"2.15.12"})
gyp: binding.gyp not found (cwd: /Users/macsupport/Downloads/core/electron/node_modules/electron-rebuild/node_modules/lzma-native/node_modules/node-addon-api) 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:520:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/macsupport/Downloads/core/electron/node_modules/electron-rebuild/node_modules/lzma-native/node_modules/node-addon-api
gyp ERR! node -v v16.14.0
gyp ERR! node-gyp -v v9.0.0
gyp ERR! not ok
npm WARN engine socks@2.6.2: wanted: {"node":">= 10.13.0","npm":">= 3.0.0"} (current: {"node":"16.14.0","npm":"2.15.12"})
npm WARN engine smart-buffer@4.2.0: wanted: {"node":">= 6.0.0","npm":">= 3.0.0"} (current: {"node":"16.14.0","npm":"2.15.12"})
npm ERR! Darwin 21.4.0
npm ERR! argv "/usr/local/bin/node" "/Users/macsupport/node_modules/.bin/npm" "i"
npm ERR! node v16.14.0
npm ERR! npm v2.15.12
npm ERR! code ELIFECYCLE
npm ERR! node-addon-api@3.2.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-addon-api@3.2.1 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the node-addon-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-addon-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-addon-api
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/macsupport/Downloads/core/electron/npm-debug.log
".] {
code: 'ERR_UNHANDLED_REJECTION'
}
To Reproduce run npx cap add @capacitor-community/electron
Expected behavior Electron should be added without this error
- OS: Monterey 12.3
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
using capacitor-community/electron to create desktop app with ...
I then go to the electron folder directory and run: npm run electron:make , but it only creates a win_unpack folder without an...
Read more >@capacitor-community/electron - npm
Start using @capacitor-community/electron in your project by running `npm i @capacitor-community/electron`. There are 4 other projects in ...
Read more >Create a Capacitor Electron Plugin - GitHub Pages
Create or open a Capacitor V3 compatible plugin in your editor of choice. Create a folder named electron in the root of this...
Read more >Capacitor Community Plugin Showcase - Ionic Blog
npm i @capacitor-community/electron npx cap add @capacitor-community/electron. An Electron project will be created in a folder titled ...
Read more >Installing Capacitor | Capacitor Documentation
Adding Capacitor to your existing web application · Install Capacitor · Initialize your Capacitor config · Create your Android and iOS projects ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone with this issue in the future. It seems I had another, old version of npm in my Users/myname/ folder, which was being utilized instead of the global, current npm version.
The error posted points to npm being very out of date, there may be something wrong with what version is being used. If you use tools like nvm make sure those are functioning properly.