Registry / devops / ninja-build

ninja-build

JSON →
library0.1.5jsnpmunverified

The `ninja-build` npm package serves as a lightweight Node.js wrapper for the Ninja build system. Its primary function is to simplify the inclusion and execution of the Ninja binary (version 1.3.4) within Node.js projects, abstracting away the manual download and compilation steps. Currently at version 0.1.5, this package is largely unmaintained, with its last update occurring many years ago. It bundles an extremely old version of Ninja (1.3.4, whereas modern Ninja is significantly higher). While initially designed for ease of use within Node.js workflows, its lack of updates, especially regarding the bundled Ninja version and explicit lack of Windows support, severely limits its utility in modern development environments. The package has no active release cadence.

npm install ninja-build
INSTALL
IMPORT
SIG · NINJA-BUILD
N
ninja-build
devopsjavascriptv0.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Ninja Binary Path (CommonJS)
const ninjaPath = require.resolve('ninja-build/bin/ninja');
import ninjaPath from 'ninja-build/bin/ninja';
This package does not export JavaScript modules. This pattern retrieves the absolute path to the bundled Ninja binary for programmatic execution using `child_process`. ESM `import` statements are not applicable here as the binary is not a JS module.
Direct Binary Execution (CLI)
./node_modules/ninja-build/bin/ninja --version
ninja --version
When installed locally, the Ninja binary is accessed directly via its path within `node_modules`. Using `ninja --version` directly only works if the package was installed globally (which is discouraged) and the binary is in the system's PATH.
Non-existent JavaScript Module Import
// No direct JavaScript import is possible as this package provides a binary.
import { build } from 'ninja-build';
This package is a binary wrapper and does not expose any JavaScript functions or classes for direct import. Attempts to import symbols will result in module not found errors or undefined values.

This quickstart demonstrates how to programmatically find and execute the bundled Ninja binary within a Node.js script using `child_process`, printing its help output.

const { spawn } = require('child_process'); const path = require('path'); // Determine the path to the Ninja binary provided by the package // This ensures the correct binary is found relative to node_modules const ninjaBinaryPath = require.resolve('ninja-build/bin/ninja'); console.log(`Attempting to execute Ninja from: ${ninjaBinaryPath}`); // Spawn a child process to execute the Ninja binary // Here, we run `ninja -h` to display help information const ninjaProcess = spawn(ninjaBinaryPath, ['-h']); ninjaProcess.stdout.on('data', (data) => { console.log(`Ninja stdout:\n${data}`); }); ninjaProcess.stderr.on('data', (data) => { console.error(`Ninja stderr:\n${data}`); }); ninjaProcess.on('close', (code) => { console.log(`Ninja process exited with code ${code}`); if (code !== 0) { console.error('Ninja execution failed. Check stderr for details.'); } });
ninja --version
Debug
Known issues
breakingThe package bundles Ninja version 1.3.4, which is extremely old (released circa 2012). This version is incompatible with many modern build scripts and lacks critical features or bug fixes present in current Ninja releases.
fix
Consider using a newer method to acquire Ninja (e.g., system package manager, direct download, or a more actively maintained npm package) if modern Ninja features or compatibility are required. This `ninja-build` package is not suitable for modern projects.
affects: >=0.1.0
gotchaThis package explicitly states it does not work on Windows due to its bootstrap script being written for `bash`. Attempting to use it on Windows will result in build failures or errors related to shell commands.
fix
Do not use this package on Windows. Users on Windows should install Ninja via other means (e.g., Chocolatey, MSYS2, or official downloads) or use a Linux/macOS environment.
affects: >=0.1.0
gotchaThe package is largely unmaintained, with the last commit several years ago. This means there will be no updates for critical bug fixes, security vulnerabilities in the bundled Ninja, or compatibility with newer Node.js versions or operating systems.
fix
Evaluate alternatives for managing the Ninja build system in your project that are actively maintained and provide a current version of Ninja.
affects: >=0.1.0
gotchaGlobal installation of `ninja-build` is discouraged by the package author due to potential version conflicts between projects. It can also lead to issues with `PATH` environment variables and finding the correct binary.
fix
Always install `ninja-build` as a development dependency (`npm install --save-dev ninja-build`) and access the binary via its `node_modules` path or a `package.json` script.
affects: >=0.1.0
Errors
Common errors & fixes
node_modules/ninja-build/bin/ninja: No such file or directory
The package installation failed, the file was removed/corrupted, or the path specified for execution is incorrect. This can happen if the build process for Ninja failed during `npm install`.
fix
Run `npm install ninja-build` again. Verify the file actually exists at the specified path (`./node_modules/ninja-build/bin/ninja`) after installation. Check `npm config get platform` and `npm config get arch` for compatibility issues.
sh: 1: bash: not found
This error occurs on Windows or environments where `bash` is not available in the system PATH, as the `ninja-build` package's internal bootstrap scripts and the Ninja build process itself depend on it.
fix
This package is explicitly not supported on Windows. Install Ninja through a Windows-native method (e.g., Chocolatey) or use a Linux/macOS environment that has `bash` installed.
Error: Cannot find module 'ninja-build' or 'ninja-build/bin/ninja'
Attempting to `require()` or `import` the package or its binary directly as a standard JavaScript module, which it is not.
fix
The `ninja-build` package does not expose a JavaScript module. To get the path to the binary, use `require.resolve('ninja-build/bin/ninja')` and then execute it via `child_process`. Do not use `import` or direct `require` on the package name itself.
Upgrade
Version history
0.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
ninja-build — npm install ninja-build · libregistry