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
I have tried to run on android a node app that includes a dependency that includes the sodium-native package and it crushes.
Does android build, rebuild the npm modules ?
No, unfortunately native packages aren't automatically rebuilt for mobile platforms. If a native package isn't built for mobile platforms, you have to do it by yourself.
Maybe we could provide an automatic rebuild of native dependencies for mobile platforms in the future. But honestly I don't see such a feature soon, as I haven't worked with native modules yet and have other priorities at the moment.
Activity
hampoelz commentedon Jul 26, 2023
No, unfortunately native packages aren't automatically rebuilt for mobile platforms. If a native package isn't built for mobile platforms, you have to do it by yourself.
I haven't tried yet, but maybe you can make use of the "override" field in your package.json. See https://docs.npmjs.com/cli/v9/configuring-npm/package-json?v=true#overrides and npm/cli#4909
You could try overriding your dependency's
sodium-nativepackage with thesodium-native-nodejs-mobilepackage, which should work on android and ios.You might try something like this for a npm module:
or for a module not hosted on npm:
Let me know if it works so I can add a note to the readme.
hampoelz commentedon Aug 26, 2023
Thanks for sharing your script @jrobeson.
Maybe we could provide an automatic rebuild of native dependencies for mobile platforms in the future. But honestly I don't see such a feature soon, as I haven't worked with native modules yet and have other priorities at the moment.
hampoelz commentedon Dec 2, 2023
Until I find time to look into it, the prebuild-for-nodejs-mobile tool could be used to compile native node.js modules for mobile devices.