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-essentialon Ubuntu).
- Linux: Install
- filerix: Ensure the
filerixlibrary and its development files are installed. If you builtfilerixmanually, ensure the.sofiles are in your library path.
Building the Node.js Wrapper with node-gyp
Navigate to the
example/nodejsdirectory:bashcd example/nodejsRun the following command to configure and build the wrapper:
bashnode-gyp configure node-gyp buildAfter building, the compiled Node.js addon (
filerix.node) will be available in thebuild/Releasedirectory.
Installation
Ensure you are in the
example/nodejsdirectory:bashcd example/nodejsInstall the required dependencies:
bashnpm install
Running the Example
The example is set up in
example/nodejs/src/index.js.- The
getDriveUsagefunction 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.sonot found), ensure the library path is correctly set:bashexport LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
