{"library":"node-gyp-build-mobile","title":"Node.js Mobile Native Addon Builder/Loader","description":"This package, `node-gyp-build-mobile`, serves as a specialized fork of the widely used `node-gyp-build` utility, meticulously adapted for the Node.js Mobile ecosystem. Its primary function is to override standard npm defaults, thereby enabling `node-mobile-gyp` to successfully compile native Node.js addons specifically for deployment on mobile platforms. The current stable version, `4.6.0-3`, reflects a unique versioning scheme that deviates from traditional Semantic Versioning. Instead, `x.y.z-a` indicates that the package is based on upstream `node-gyp-build` version `x.y.z`, with the `a` component acting as an internal incrementer for `node-gyp-build-mobile`'s own releases. This ensures compatibility and specific optimizations required for the mobile Node.js runtime. As a core component, it is essential for developers engaged in building and integrating C++ or other native modules within Node.js Mobile applications, providing the necessary build-time environment to correctly locate and link prebuilt binaries or compile source code against the target mobile architecture.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-gyp-build-mobile"],"cli":null},"imports":["import findNativeAddon from 'node-gyp-build-mobile';","const findNativeAddon = require('node-gyp-build-mobile');","\"install\": \"node-gyp-build-mobile --fallback-to-build\""],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"{\n  \"name\": \"my-mobile-native-module\",\n  \"version\": \"1.0.0\",\n  \"description\": \"A native Node.js Mobile module that uses node-gyp-build-mobile.\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"install\": \"node-gyp-build-mobile --fallback-to-build\",\n    \"test-mobile-load\": \"node index.js\"\n  },\n  \"dependencies\": {\n    \"node-gyp-build-mobile\": \"^4.6.0-3\"\n  },\n  \"keywords\": [\n    \"nodejs-mobile\",\n    \"native-addon\",\n    \"gyp\",\n    \"build\"\n  ]\n}\n\n// index.js (within the native module package)\nconst path = require('path');\nconst findAddon = require('node-gyp-build-mobile');\n\nlet myNativeModule;\ntry {\n  // The findAddon function takes the directory of the package.json for the native module\n  myNativeModule = findAddon(__dirname);\n  console.log('Native module loaded successfully for Node.js Mobile.');\n  // Example: If the native module exports a 'greet' function\n  // if (typeof myNativeModule.greet === 'function') {\n  //   console.log('Greeting from native module:', myNativeModule.greet('Mobile User'));\n  // }\n} catch (error) {\n  console.error('Failed to load native module for Node.js Mobile:', error.message);\n  console.error('Ensure node-gyp-build-mobile ran successfully during install.');\n  process.exit(1);\n}\n\n// Log the loaded module (could be an object or a function depending on native addon)\nconsole.log('Loaded native module object:', myNativeModule);","lang":"javascript","description":"Demonstrates how to integrate `node-gyp-build-mobile` into a `package.json` `install` script to build or locate a native addon for Node.js Mobile, and how the addon's main file uses `node-gyp-build-mobile` to load itself at runtime.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}