Node.js Usage
Prerequisites
Before proceeding, ensure the following are installed and set up:
- Node.js: Install the latest LTS version from Node.js official site.
- Python: Required by
node-gyp
. Install Python 3.x. - Build Tools:
- Linux: Install
build-essential
(e.g.,sudo apt install build-essential
on Ubuntu).
- Linux: Install
- filerix: Ensure the
filerix
library and its development files are installed. If you builtfilerix
manually, ensure the.so
files are in your library path.
Building the Node.js Wrapper with node-gyp
Navigate to the
example/nodejs
directory:bashcd example/nodejs
Run the following command to configure and build the wrapper:
bashnode-gyp configure node-gyp build
After building, the compiled Node.js addon (
filerix.node
) will be available in thebuild/Release
directory.
Installation
Ensure you are in the
example/nodejs
directory:bashcd example/nodejs
Install the required dependencies:
bashnpm install
Running the Example
The example is set up in
example/nodejs/src/index.js
.- The
getDriveUsage
function fetches and logs the disk usage information for a given path.
- The
To run the example:
bashnode src/index.js
Common issues
- If you encounter issues with library loading (e.g.,
filerix.so
not found), ensure the library path is correctly set:bashexport LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH