What You”ll Need
- Node.js source at v25.5.0 (clone from the Node.js Git repository)
- Git and developer tools: gcc/clang, make or MSVC, CMake, and Python 3 for build scripts
- Network access to download LIEF artifacts or source (or access to cached/proxied artifacts in CI)
- Optional: credentials for internal artifact registry if your environment blocks public downloads
How It Works
The Node.js v25.5.0 release added scripts and helper tooling inside the deps area to fetch LIEF as a third-party dependency. The tooling can either download prebuilt platform-specific LIEF binaries or clone and build LIEF from source, then place headers and libraries where Node”s build system can consume them.
At a high level the workflow is: locate the provided fetch/build script in the source tree, run it with platform and version options (or rely on defaults), set environment variables (for example LIEF_ROOT or LIEF_DIR) that point to the fetched artifacts, then reconfigure and rebuild Node so the linker and compiler pick up LIEF. The scripts are intended to simplify CI pipelines and local builds by encapsulating retrieval and install steps.
Step-by-Step Guide
🔔 Never Miss a Breaking Change
Get weekly release intelligence — breaking changes, security patches, and upgrade guides before they break your build.
✅ You're in! Check your inbox for confirmation.
[nodejs] pull LIEF dependency
- Get the correct Node source: git clone –branch v25.5.0 https://github.com/nodejs/node.git && cd node
- Inspect the deps tooling: look under
deps/andtools/for LIEF fetch scripts (filenames often start with “lief” or “fetch-lief”). Read script –help or header comments to learn supported options like –version, –arch, –platform, and –prefix. - Fetch prebuilt LIEF (fast): run the provided fetch script with your platform and arch flags to download prebuilt artifacts. Example pattern:
./tools/deps/fetch-lief --platform linux --arch x64 --out deps/lief. If your script supports it, pass –version to pin a LIEF release. - Or build LIEF from source (if needed): if your environment requires a source build, use the script”s build mode or run CMake in the fetched LIEF source directory: configure with a preferred generator (Ninja/MSBuild), then build and install into a local prefix, e.g.,
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=deps/lief/install && cmake --build build --target install. - Point Node”s build to LIEF: set environment variables so Node”s configure can find LIEF, for example
export LIEF_ROOT=$(pwd)/deps/lief(or setLIEF_DIR/LIEF_PREFIXdepending on the provided scripts). Then run./configureand verify the output mentions LIEF include and lib paths. - Rebuild Node and verify: run
make -jor the platform appropriate build command. After build, run any tests that exercise binary parsing or native modules that link to LIEF, and verify symbols are resolved and runtime loads succeed.
Use Cases & Examples
- Local development for a native addon: you need LIEF headers and libs to compile an addon that inspects ELF/PE files. Use the fetch script to install LIEF into deps/lief, set
LIEF_ROOT, then compile your addon against those headers so CI and local dev match. - CI pipeline with cached artifacts: in CI, run the fetch step once and cache the installed
deps/liefdirectory between jobs. This avoids building LIEF repeatedly. The scripts added in v25.5.0 are meant to be deterministic so caches remain valid across runs. - Security tooling inside Node: if you add a diagnostic tool to Node that uses LIEF to parse binaries at runtime, pulling LIEF via the deps scripts ensures your production builds reference the same LIEF ABI that tests used during development.
Common Issues
- Network blocked: if downloads fail, mirror the LIEF artifacts to an internal registry and pass the script a –prefix or –mirror option, or download and place files under
deps/liefmanually. - ABI or version mismatch: Problem: Node build picks a different LIEF version than expected. Solution: pin the LIEF version with the script”s –version flag and clear any stale build caches before rebuilding.
- Missing headers at configure: Problem: configure can”t find
LIEFheaders. Solution: ensureLIEF_ROOT(or the script”s configured prefix) points to the install that containsinclude/andlib/, and rerun./configure. - Linker errors on Windows: Problem: unresolved externals. Solution: ensure you built LIEF with the same runtime and MSVC toolset as Node, and that .lib files are on the lib path referenced by the build.
What”s Next
- Integrate the LIEF fetch step into your CI cache strategy to speed builds
- Explore writing a Node native addon that uses LIEF APIs for binary inspection
- Track upstream LIEF releases and update the pinned LIEF version in your build scripts
Related Resources
- Node.js v25.5.0 release guide
- Official LIEF documentation: https://lief.quarkslab.com/
- Node.js BUILDING.md and developer docs for configuring third-party deps