Skip to content

Attempting to require a nodejs addon causes the app to crash #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
coreyphillips opened this issue Aug 13, 2020 · 3 comments
Closed

Attempting to require a nodejs addon causes the app to crash #278

coreyphillips opened this issue Aug 13, 2020 · 3 comments

Comments

@coreyphillips
Copy link

coreyphillips commented Aug 13, 2020

  • Project: nodejs-mobile-react-native
  • Version: 0.6.1
  • Mobile device: iPhone 11 Simulator
  • Mobile OS and version: iOS Simulator Version 11.6 (921.9.1)
  • Development Node.js: v10.15.1
  • Development platform: Darwin 19.5.0 Darwin Kernel Version 19.5.0: RELEASE_X86_64 x86_64

Has anyone else had any luck utilizing a .node nodejs addon with nodejs-mobile-react-native? Attempting to require the .node file appears to crash the app.

@coreyphillips coreyphillips changed the title Receiving an error when attempting to require a nodejs addon Attempting to require a nodejs addon causes the app to crash Aug 14, 2020
@coreyphillips
Copy link
Author

I created a project here that should reproduce the error and crash the app once the try/catch is removed from the main.js file here.

@coreyphillips
Copy link
Author

It turns out the errors I'm receiving are the following:

iOS:
Error: dlopen(/private/var/containers/Bundle/Application/ED3FDD4B-524A-4C81-9489-AA3033180524/nodeAddonAttempt.app/nodejs-project/rgb_node.node, 0x0001): could not use '/private/var/containers/Bundle/Application/ED3FDD4B-524A-4C81-9489-AA3033180524/nodeAddonAttempt.app/nodejs-project/rgb_node.node' because it is not a compatible arch

Android:
Error: dlopen failed: \"/data/data/com.nodeAddonAttempt/files/nodejs-project/rgb_node.node\" has bad ELF magic: cffaedfe

Possibly an issue with how the nodejs addon is built? If so, how would I include the mobile architechtures into the addon for use in nodejs-mobile-react-native?

@jaimecbernardo
Copy link
Member

Hi @coreyphillips ,
This looks like the native module is not built for Android and/or iOS (the .node file here.
The react-native-module has a way to rebuild native modules when the .gyp and source files are inside node_modules when you are building the application, by setting the right environment variables to use the nodejs-mobile headers, use nodejs-mobile-gyp, set the right architectures and so on.

#4
JaneaSystems/nodejs-mobile-gyp#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants