Problems with native modules
See original GitHub issueMy workflow for an electron app is
# Install all dependencies, including native modules
npm install
# Ensure native modules are built to match electron
./node_modules/.bin/electron-rebuild
# Test the app
./node_modules/.bin/electron .
# package the app
./node_modules/.bin/electron-packager . \"MyApp\" --out=dist/osx --platform=darwin --arch=x64 --version=0.33.6 --icon=assets/osx/myicon.icn
# build a distribution
./node_modules/.bin/electron-builder \"dist/osx/MyApp-darwin-x64/MyApp.app\" --platform=osx --out=\"dist/osx\" --config=packager.json"
The last step is failing with the following error:
- Starting build for ´osx´ -
Writing temporary ´appdmg.json´
Wrote temporary ´appdmg.json´
Kicking off ´appdmg´
module.js:355
Module._extensions[extension](this, filename);
^
Error: Module version mismatch. Expected 14, got 46.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/xxx/projects/myapp/myapp/electron/node_modules/electron-builder/node_modules/appdmg/node_modules/ds-store/node_modules/macos-alias/lib/create.js:7:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
I believe this is happening because the electron-builder script is running using a node implementation incompatible with electron (which is why the electron-rebuild script is necessary):
$ npm --version
2.5.1
$ node --version
v0.12.0
$ ./node_modules/.bin/electron --version
v0.33.6
Is this a bug? What is the recommended way to build build distributions with native modules?
Issue Analytics
- State:
- Created 8 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Troubleshooting Native Modules · React Native for Windows + ...
C++ apps consuming native modules written in C# need special care. There is a bug in the interop between C# and C++: https://github.com/microsoft/dotnet/issues/ ......
Read more >Native Modules · Issue #96 · react-native-community ... - GitHub
Working with native modules in React Native can be overwhelming. From the library author perspective, it is not clear how native dependencies ...
Read more >React-native Native Modules Official Guide not working
I've tried following this guide 10 times today: https://reactnative.dev/docs/native-modules ...
Read more >Bridging the Gap: Native Modules and React Native
The perceived difficulty of Native module integration has been a barrier to using React Native for cross-platform development. Here's a simple solution.
Read more >Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Enjoy. Version 8 will be released soon. You are not forced to use two package.json structure anymore.
Similar problem here.
Cannot find module 'module_name'
in production build, but dev mode works well. All missed modules was not listed in package.jsondependencies
so I have to manually install them and it works.