question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with native modules

See original GitHub issue

My 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:closed
  • Created 8 years ago
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
develarcommented, Nov 10, 2016
  1. electron-builder doesn’t use appdmg module anymore — no dev native deps from electron-builder anymore.
  2. electron-builder is smart now — dev native deps NEVER will be rebuild. Only production deps.

Enjoy. Version 8 will be released soon. You are not forced to use two package.json structure anymore.

0reactions
negamaxicommented, Nov 20, 2017

Similar problem here. Cannot find module 'module_name' in production build, but dev mode works well. All missed modules was not listed in package.json dependencies so I have to manually install them and it works.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found