We are unable to use gRPC with electron v6.
Start with an empty directory. Setup electron and grpc:
yarn add [email protected]
yarn add grpc
Re-buliding grpc for electron returns an error:
npm rebuild --runtime=electron --target=6.0.1
Traceback:
> [email protected] postinstall /Users/davidkell/dev/node_modules/electron
> node install.js
> [email protected] install /Users/davidkell/dev/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.22.2/electron-v6.0-darwin-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v6.0 ABI, unknown) (falling back to source compile with node-gyp)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://nodejs.org/dist/v6.0.1/node-v6.0.1-headers.tar.gz
gyp ERR! stack at Request.<anonymous> (/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:214:14)
gyp ERR! stack at Request.emit (events.js:203:15)
gyp ERR! stack at Request.onRequestResponse (/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/request/request.js:1066:10)
gyp ERR! stack at ClientRequest.emit (events.js:198:13)
gyp ERR! stack at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
gyp ERR! stack at TLSSocket.socketOnData (_http_client.js:442:20)
gyp ERR! stack at TLSSocket.emit (events.js:198:13)
gyp ERR! stack at addChunk (_stream_readable.js:288:12)
gyp ERR! stack at readableAddChunk (_stream_readable.js:269:11)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node" "/Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node" "--module_name=grpc_node" "--module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v6.0"
gyp ERR! cwd /Users/davidkell/dev/node_modules/grpc
gyp ERR! node -v v10.16.0
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 '/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node /Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v6.0' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/davidkell/dev/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:198:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Darwin 18.6.0
node-pre-gyp ERR! command "/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node" "/Users/davidkell/dev/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd /Users/davidkell/dev/node_modules/grpc
node-pre-gyp ERR! node -v v10.16.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute '/Users/davidkell/.nvm/versions/node/v10.16.0/bin/node /Users/davidkell/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown/grpc_node.node --module_name=grpc_node --module_path=/Users/davidkell/dev/node_modules/grpc/src/node/extension_binary/electron-v6.0-darwin-x64-unknown --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=electron-v6.0' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/davidkell/.npm/_logs/2019-08-08T23_18_33_650Z-debug.log
Got the same issue with similar versions.
Is there a workaround for that or any plan to fix this soon?
Version 1.23.0 is now out with Electron 6 support. Please try that version.
it works perfectly, thanks :)
Fixed, thanks for that.
Version 1.23.0 is now out with Electron 6 support. Please try that version.
How can I run the proper commands? I've installed "grpc": "^1.23.3" and "electron": "^6.0.4" and I'm attempting to rebuild using
npm rebuild --runtime=electron --target=6.0.4
But I am not having any luck
How is it failing?
I'm on OSX 10.14.6
You can see at the start of the command that it tries to build using gRPC 1.22
MacBook-Pro-6:fmullen$ npm rebuild --runtime=electron --target=6.0.0
> [email protected] postinstall /Users/fmullen/code/megabot/node_modules/electron
> node install.js
> [email protected] postinstall /Users/fmullen/code/megabot/node_modules/protobufjs
> node scripts/postinstall
> [email protected] install /Users/fmullen/code/megabot/node_modules/@firebase/firestore/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.22.2/electron-v6.0-darwin-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v6.0 ABI, unknown) (falling back to source compile with node-gyp)
[... lots of *.o files compiling]
In file included from ../deps/grpc/src/boringssl/err_data.c:18:
In file included from /Users/fmullen/Library/Caches/node-gyp/6.0.0/include/node/openssl/err.h:115:
/Users/fmullen/Library/Caches/node-gyp/6.0.0/include/node/openssl/e_os2.h:276:11: error: 'OPENSSL_EXPORT' macro redefined [-Werror,-Wmacro-redefined]
# define OPENSSL_EXPORT extern
[... more errors]
There are about ~20 errors regarding macro redefined.
But I think I just need to somehow change to gRPC 1.23 as mentioned above. Just not sure how to do that.
I've deleted node_modules as well as package-lock.json but I am always seeing 1.22 used. Do I have to install 1.23 inside the electron folder?
npm rebuild doesn't install new versions of the library. You have to actually run npm install to get the new version.
Yes, that is correct. I can confirm that I have 1.23 listed in my package.json and this is still the behavior I see after running npm install. Is there something else I need to do in order to update the package?
What if you move the package.json file to a new directory and run npm install? What version of grpc do you get?
I think I found the issue. Even in a new directory, the script still ran with 1.22.2 so I cleaned out all other dependencies from package.json and started adding them back in one at a time.
The problem turned up again when I added firebase (needed for this project).
After upgrading from version 6.4.2 to the latest 6.5.0 the problem went away.
Hopefully this will help someone else.
Thanks for looking into it @murgatroid99
for further reference, here is the offending section in package-lock.json
"@firebase/firestore": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.5.0.tgz",
"integrity": "sha512-apZIwUWfWnIqoYD5QjpDKmZ9H5ghmT5wFJKMQsmniU+uQYaMo4CtQYcmw+WdvwAUXfqRBAaP0l/UErr4aqcn9w==",
"requires": {
"@firebase/firestore-types": "1.5.0",
"@firebase/logger": "0.1.23",
"@firebase/util": "0.2.26",
"@firebase/webchannel-wrapper": "0.2.25",
"@grpc/proto-loader": "^0.5.0",
**"grpc": "1.22.2",**
"tslib": "1.10.0"
}
}
Hi @felipemullen wondering which versions of Electron and firebase you are using for this. I am having the same issue. I have tried Electron v 6.0.11 & 6.1.0 & 7.0.0 along with Firebase 6.4.2 & 6.5.0 & 7.2.1
It looks like there has been some talk of this on the firebase js repo see:
https://github.com/firebase/firebase-js-sdk/issues/1783
but for the time being the latest version of firebase's lockfile still looks like:
"@firebase/[email protected]":
version "1.6.2"
...
dependencies:
"@firebase/firestore-types" "1.6.2"
"@firebase/logger" "0.1.27"
"@firebase/util" "0.2.30"
"@firebase/webchannel-wrapper" "0.2.28"
"@grpc/proto-loader" "^0.5.0"
grpc "1.24.0"
tslib "1.10.0"
@nkndy these are the relevant versions listed in my package-lock file
"electron": {
"version": "6.0.6",
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.6.tgz",
...
},
...
"firebase": {
"version": "6.5.0",
...
"requires": {
"@firebase/app": "0.4.15",
"@firebase/app-types": "0.4.3",
"@firebase/auth": "0.11.8",
"@firebase/database": "0.5.1",
"@firebase/firestore": "1.5.0",
"@firebase/functions": "0.4.16",
"@firebase/installations": "0.2.5",
"@firebase/messaging": "0.4.9",
"@firebase/performance": "0.2.17",
"@firebase/polyfill": "0.3.20",
"@firebase/storage": "0.3.10",
"@firebase/util": "0.2.26"
}
},
"@firebase/firestore": {
"version": "1.5.0",
...
"dependencies": {
"grpc": {
"version": "1.23.3",
"resolved": "https://registry.npmjs.org/grpc/-/grpc-1.23.3.tgz",
"integrity": "sha512-7vdzxPw9s5UYch4aUn4hyM5tMaouaxUUkwkgJlwbR4AXMxiYZJOv19N2ps2eKiuUbJovo5fnGF9hg/X91gWYjw==",
"requires": {
"@types/bytebuffer": "^5.0.40",
"lodash.camelcase": "^4.3.0",
"lodash.clone": "^4.5.0",
"nan": "^2.13.2",
"node-pre-gyp": "^0.13.0",
"protobufjs": "^5.0.3"
},
...
}
}
},
I don't remember 100% but I may have actually edited the package-lock file manually in order to make this work. My statement about the upgrade making it work was a false positive, I just forgot to come back here and edit my comment.
That's why if you compare what I am currently using with my previous snippet, you will see that the old snippet lists firestore 1.5.0 with grpc 1.22.2 whereas the one here shows the same firestore with a newer grpc
I'm sorry, Electron 6 support got broken in grpc 1.24.0. But it is fixed in grpc 1.24.1
Version 1.23.0 is now out with Electron 6 support. Please try that version.
thank you for your advice and how about nested dependencies?
@Randyshu2018 if you are still having issues with nested dependencies (like firebase) you can try using the electron-rebuild package, it solved the issues for me without configuration changes.
I posted an answer here:
https://stackoverflow.com/questions/52156883/error-with-firebase-on-electron-app-failed-to-load-grpc/59299826#59299826
Most helpful comment
Version 1.23.0 is now out with Electron 6 support. Please try that version.