Skip to content
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

Add support for nodejs-mobile #704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jaimecbernardo
Copy link

Hi,
nodejs-mobile is a fork of node used to run Node.js applications on Android and iOS.

It also allows building and running native modules. For this, it tries to use nodejs-mobile-gyp instead of node-gyp. The way it does this is setting the npm_config_node_gyp to point to nodejs-mobile-gyp. However, npm, since v7+, has started overwriting this environment variable before passing it to modules, such as node-pre-gyp.

This PR makes it so we check for the NODEJS_MOBILE_GYP environment variable to try to set node_gyp's location before trying the other methods. This variable is already used in some projects related to nodejs-mobile, so we decided to pick it:
https://github.com/nodejs-mobile/prebuild-for-nodejs-mobile/blob/44687f6cb4c0375e0f4ef063ce3321350f159241/bin.js#L367
https://github.com/nodejs-mobile/nodejs-mobile-react-native/blob/794f395152f25d1c5ccf9cc794eafa8ce58ad541/scripts/ios-build-native-modules.sh#L116
https://github.com/nodejs-mobile/nodejs-mobile-react-native/blob/794f395152f25d1c5ccf9cc794eafa8ce58ad541/android/build.gradle#L433
https://github.com/okhiroyuki/nodejs-mobile-cordova/blob/9d02c76700bba851241922d7632555546b4ee771/src/android/build.gradle#L243

The original motivation for this change was building sqlite3, which uses "@mapbox/node-pre-gyp", for nodejs-mobile. This is currently possible by adding this overrides field to a package.json of a project that's using sqlite3, but in theory it should help improve compatibility with other modules as well:

  "overrides": {
    "sqlite3": {
      "@mapbox/node-pre-gyp": "github:JaneaSystems/mapbox-node-pre-gyp#add-support-for-nodejs-mobile"
    }
  }

We'd consider this change would be safe for current uses, since in theory a process which sets an environment variable called NODEJS_MOBILE_GYP is likely to want to build for nodejs-mobile.

@staltz , FYI, since this information may help unblock building other modules in nodejs-mobile.

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

Successfully merging this pull request may close these issues.

None yet

1 participant