source: node_modules/bindings/README.md@ 81bc7da

finki-main main
Last change on this file since 81bc7da was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 3.4 KB
Line 
1node-bindings
2=============
3### Helper module for loading your native module's `.node` file
4
5This is a helper module for authors of Node.js native addon modules.
6It is basically the "swiss army knife" of `require()`ing your native module's
7`.node` file.
8
9Throughout the course of Node's native addon history, addons have ended up being
10compiled in a variety of different places, depending on which build tool and which
11version of node was used. To make matters worse, now the `gyp` build tool can
12produce either a __Release__ or __Debug__ build, each being built into different
13locations.
14
15This module checks _all_ the possible locations that a native addon would be built
16at, and returns the first one that loads successfully.
17
18
19Installation
20------------
21
22Install with `npm`:
23
24``` bash
25$ npm install --save bindings
26```
27
28Or add it to the `"dependencies"` section of your `package.json` file.
29
30
31Example
32-------
33
34`require()`ing the proper bindings file for the current node version, platform
35and architecture is as simple as:
36
37``` js
38var bindings = require('bindings')('binding.node')
39
40// Use your bindings defined in your C files
41bindings.your_c_function()
42```
43
44
45Nice Error Output
46-----------------
47
48When the `.node` file could not be loaded, `node-bindings` throws an Error with
49a nice error message telling you exactly what was tried. You can also check the
50`err.tries` Array property.
51
52```
53Error: Could not load the bindings file. Tried:
54 → /Users/nrajlich/ref/build/binding.node
55 → /Users/nrajlich/ref/build/Debug/binding.node
56 → /Users/nrajlich/ref/build/Release/binding.node
57 → /Users/nrajlich/ref/out/Debug/binding.node
58 → /Users/nrajlich/ref/Debug/binding.node
59 → /Users/nrajlich/ref/out/Release/binding.node
60 → /Users/nrajlich/ref/Release/binding.node
61 → /Users/nrajlich/ref/build/default/binding.node
62 → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
63 at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
64 at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
65 at Module._compile (module.js:449:26)
66 at Object.Module._extensions..js (module.js:467:10)
67 at Module.load (module.js:356:32)
68 at Function.Module._load (module.js:312:12)
69 ...
70```
71
72The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
73
74License
75-------
76
77(The MIT License)
78
79Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
80
81Permission is hereby granted, free of charge, to any person obtaining
82a copy of this software and associated documentation files (the
83'Software'), to deal in the Software without restriction, including
84without limitation the rights to use, copy, modify, merge, publish,
85distribute, sublicense, and/or sell copies of the Software, and to
86permit persons to whom the Software is furnished to do so, subject to
87the following conditions:
88
89The above copyright notice and this permission notice shall be
90included in all copies or substantial portions of the Software.
91
92THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
93EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
94MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
95IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
96CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
97TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
98SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note: See TracBrowser for help on using the repository browser.