Ninja Build System Wrapper

0.1.5 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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.');
  }
});

view raw JSON →