You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The module '/Users/Me/Devel/electron-python-example/node_modules/zeromq/build/Release/zmq.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 54. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
at process.module.(anonymous function) [as dlopen]
because specifying "electron": "^1.7.6", these days (2018) will cause npm to actually pick up electron 1.8.4 - which won't work with your custom zerorpc version.
This is because the ^ symbol in package.json means the latest available 1.* version of electron is searched for and installed, see npm versioning.
I finally got the example to work by removing the ^
thus causing that exact version of electron to be installed, which matches your 'prebuilt' zerorpc dependency "zerorpc": "git+https://github.com/fyears/zerorpc-node.git".
I believe that the readme should be updated to remove the ^ from package.json to help users avoid this problem.
Turns out that the module mismatch problem can be fixed by installing electron-rebuild
npm install --save-dev electron-rebuild
and running it after npm install. This step's purpose is to rebuild native Node.js modules against the version of Node.js that your Electron project is using. Remember that electron comes with its own internal version of node. The rebuild step will rebuild the node module zerorpc from fyear's custom repository to work with whatever version of electron happens to get installed when you npm install.
# install dependencies based on the package.json first
npm install
#every time you run 'npm install',you have to run this:
./node_modules/.bin/electron-rebuild
# run
./node_modules/.bin/electron .
This means we don't need to remove the ^ from package.json. Whatever version of electron is installed, the rebuild step will repair any module mismatch issues.
Reacted by Elliot Pahel-Short, Javier, John King, Danny Wang and issaysa
@abulka, thanks for the above. Did you manage to pack the application? I manage to compile it ok, but still, have the same error when running the generated executable(MODULE_VERSION...). I tried adding the argument --electron-version=1.7.6 to electron-packager but didn't solve it.
I run this bash script to do the whole thing at once:
rm -rf ~/.node-gyp
rm -rf ~/.electron-gyp
rm -rf ./node_modules
npm install --save-dev electron-rebuild
# install dependencies based on the package.json first
npm install --runtime=electron --target=1.7.6
#every time you run 'npm install',you have to run this:
./node_modules/.bin/electron-rebuild
# run (works great)
./node_modules/.bin/electron .
# Build python app
pyinstaller pycalc/api.py --distpath pycalcdist
rm -rf build/
rm -rf api.spec
# build Electron app
./node_modules/.bin/electron-packager . --electron-version=1.7.6 --overwrite --ignore="pycalc$" --ignore="\.venv" --ignore="old-post-backup"
I am also running into the error @jafermarq pointed out. Specifically, I'm getting the error cannot find module 'zerorpc' in the chromium console once i try to launch the app. I'm thinking that electron-rebuild has to be integrated with electron-packager, which is documented on the electron-rebuild github page.
When you use the electron packager, change the '--electron-version' tag to the version of electron that packages are being rebuild to (1.8.4). And make sure that all of the node modules are being included by using the '--no-prune' flag.
Activity
abulka commentedon Mar 25, 2018
Turns out that the module mismatch problem can be fixed by installing electron-rebuild
and running it after npm install. This step's purpose is to rebuild native Node.js modules against the version of Node.js that your Electron project is using. Remember that electron comes with its own internal version of node. The rebuild step will rebuild the node module
zerorpcfrom fyear's custom repository to work with whatever version of electron happens to get installed when you npm install.This means we don't need to remove the ^ from package.json. Whatever version of electron is installed, the rebuild step will repair any module mismatch issues.
jafermarq commentedon Apr 2, 2018
@abulka, thanks for the above. Did you manage to pack the application? I manage to compile it ok, but still, have the same error when running the generated executable(MODULE_VERSION...). I tried adding the argument
--electron-version=1.7.6toelectron-packagerbut didn't solve it.I run this bash script to do the whole thing at once:
yeshymanoharan commentedon Apr 18, 2018
I am also running into the error @jafermarq pointed out. Specifically, I'm getting the error
cannot find module 'zerorpc'in the chromium console once i try to launch the app. I'm thinking that electron-rebuild has to be integrated with electron-packager, which is documented on the electron-rebuild github page.yeshymanoharan commentedon Apr 18, 2018
ok @jafermarq I found the error.
When you use the electron packager, change the '--electron-version' tag to the version of electron that packages are being rebuild to (1.8.4). And make sure that all of the node modules are being included by using the '--no-prune' flag.