bindings
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
file-uri-to-path | 1.0.0 | 3.47 kB | MIT | prod |
Bindings is a versatile Node.js helper module for native addon authors that simplifies the process of loading a native module's '.node' file. Throughout Node's history, addons have been compiled in numerous places depending on the build tool or Node version used. Add to the mix that the gyp
tool creates either a Debug or Release build each in varying locations and you have a difficult time keeping track. This is where Bindings comes to the rescue. It checks all potential build locations for a native addon, returning the first one that loads successfully.
The usage of the Bindings module is straightforward. After installing it with npm using the command npm install --save bindings
, or including it in the "dependencies" section of your package.json file, you can call it in your Node.js code like this:
var bindings = require('bindings')('binding.node')
// Use your bindings defined in your C files
bindings.your_c_function()
This code will require()
the appropriate bindings file for the current Node version, platform, and architecture. If the .node
file cannot be loaded, node-bindings
throws an Error with a clear message outlining what was attempted. You can also examine the err.tries
Array property for more information.
The documentation for the Bindings module comes primarily from their GitHub page. It's located at git://github.com/TooTallNate/node-bindings.git, providing all the information you need to understand how the module works and how to incorporate it into your projects. You'll find descriptions explaining the purpose of the module, the installation process, usage syntax, and examples. Should there be any updates or changes to the module, this page will be the first place where you will find such crucial information.