Node.js Binary Addon File
3.4 | 9 Votes
What is a NODE file?
A NODE file contains an addon, which is a compiled library of functions used by one or more Node.js applications. It stores binary data compiled from a GYP file written in the C++ programming language. NODE files are similar to .MJS modules in that they allow web and application developers to organize code into smaller reusable components.
Web and app developers utilize NODE files to create addons for Node.js applications. These addons allow Node.js applications to link to libraries that provide functionality. A reusable addon project typically consists of a package.json file, a binding.gyp file, and C++ source code, whereas non-reusable modules don't need the package.json file.
To create NODE files, the developers first install the "node-gyp" utility bundled with Node.js using the following command:
npm install -g node-gyp
Then, the developers create binding.gyp files that describe the build configuration of the Node.js module. They then use the node-gyp configure command to create the proper build files and utilize the node-gyp build command to create the addon.node file.
NOTE: To load an addon as a Node.js module, use the require() function.