javascriptsqliteelectronnode-gypfsevents

Electron cannot build platform dependencies fsevents and/or sqllite on OS X


I want to distribute my web-app to OS X using electron. During adaptation it for electron extra dependencies of sqlite3 and fsevents were used. To successfully run the app locally I had to rebuild them using ./node_modules/.bin/electron-rebuild -p -t "dev,prod,optional" And now when I run electron . the app works like a charm. But when I'm trying to pack it by electron-packer . it fails to build production dependencies and fails packing at all.

...
To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • writing effective config file=dist/builder-effective-config.yaml
  • rebuilding native production dependencies platform=darwin arch=x64
Error: npm exited with code 1
Output:

> sqlite3@4.0.6 install /Users/home/Projects/app_desktop/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

Failed to execute '/usr/local/Cellar/node@8/8.15.1/bin/node /usr/local/Cellar/node@8/8.15.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean' (1)

Error output:
node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.6/electron-v4.1-darwin-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.0.6 and electron@4.1.0 (electron-v4.1 ABI, unknown) (falling back to source compile with node-gyp) 
gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, unlink 'build/Makefile'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/Cellar/node@8/8.15.1/bin/node" "/usr/local/Cellar/node@8/8.15.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean"
gyp ERR! cwd /Users/home/Projects/app_desktop/node_modules/sqlite3
gyp ERR! node -v v8.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node@8/8.15.1/bin/node /usr/local/Cellar/node@8/8.15.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js clean' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/home/Projects/app_desktop/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:915:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/Cellar/node@8/8.15.1/bin/node" "/Users/home/Projects/app_desktop/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/home/Projects/app_desktop/node_modules/sqlite3
node-pre-gyp ERR! node -v v8.15.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@4.0.6 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/home/.npm/_logs/2019-03-26T18_47_44_705Z-debug.log

    at ChildProcess.childProcess.once.code (/usr/local/lib/node_modules/electron-builder/node_modules/builder-util/src/util.ts:244:14)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Socket.stream.socket.on (internal/child_process.js:336:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:561:12)
From previous event:
    at _rebuild (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/util/yarn.ts:179:5)
    at rebuild (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/util/yarn.js:163:19)
    at /usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/util/yarn.ts:20:11
    at Generator.next (<anonymous>)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at _installOrRebuild (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/util/yarn.js:71:28)
    at installOrRebuild (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/out/util/yarn.js:55:28)
    at /usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:509:13
    at Generator.next (<anonymous>)
From previous event:
    at Packager.installAppDependencies (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:470:70)
    at /usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:420:20
    at Generator.next (<anonymous>)
From previous event:
    at Packager.doBuild (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:396:24)
    at /usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:366:57
    at Generator.next (<anonymous>)
    at /usr/local/lib/node_modules/electron-builder/node_modules/graceful-fs/graceful-fs.js:111:16
    at /usr/local/lib/node_modules/electron-builder/node_modules/graceful-fs/graceful-fs.js:45:10
    at FSReqWrap.oncomplete (fs.js:135:15)
From previous event:
    at Packager._build (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:335:133)
    at /usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:331:23
    at Generator.next (<anonymous>)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at Packager.build (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/packager.ts:288:14)
    at build (/usr/local/lib/node_modules/electron-builder/node_modules/app-builder-lib/src/index.ts:59:28)
    at build (/usr/local/lib/node_modules/electron-builder/src/builder.ts:228:10)
    at then (/usr/local/lib/node_modules/electron-builder/src/cli/cli.ts:46:19)
    at <anonymous>

I have no idea where to start troubleshooting of this.


Solution

  • Before get this error, I didn't read the complete error message the first time node-gyp failed, so I just ran sudo ... to see if it was magically solved, but got this EACCESS error after that.

    Later I realized that my sudo attempt screwed the permissions of my node_modules, removed it all with -Rf and reinstalled. The original node-gyp issue seems related to a current issue with the package for me.