{"id":14726,"library":"ninja-build","title":"Ninja Build System Wrapper","description":"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.","status":"abandoned","version":"0.1.5","language":"javascript","source_language":"en","source_url":"git://github.com/undashes/ninja-build","tags":["javascript","ninja","build","system","wrapper"],"install":[{"cmd":"npm install ninja-build","lang":"bash","label":"npm"},{"cmd":"yarn add ninja-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add ninja-build","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"import ninjaPath from 'ninja-build/bin/ninja';","symbol":"Ninja Binary Path (CommonJS)","correct":"const ninjaPath = require.resolve('ninja-build/bin/ninja');"},{"note":"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.","wrong":"ninja --version","symbol":"Direct Binary Execution (CLI)","correct":"./node_modules/ninja-build/bin/ninja --version"},{"note":"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.","wrong":"import { build } from 'ninja-build';","symbol":"Non-existent JavaScript Module Import","correct":"// No direct JavaScript import is possible as this package provides a binary."}],"quickstart":{"code":"const { spawn } = require('child_process');\nconst path = require('path');\n\n// Determine the path to the Ninja binary provided by the package\n// This ensures the correct binary is found relative to node_modules\nconst ninjaBinaryPath = require.resolve('ninja-build/bin/ninja');\n\nconsole.log(`Attempting to execute Ninja from: ${ninjaBinaryPath}`);\n\n// Spawn a child process to execute the Ninja binary\n// Here, we run `ninja -h` to display help information\nconst ninjaProcess = spawn(ninjaBinaryPath, ['-h']);\n\nninjaProcess.stdout.on('data', (data) => {\n  console.log(`Ninja stdout:\\n${data}`);\n});\n\nninjaProcess.stderr.on('data', (data) => {\n  console.error(`Ninja stderr:\\n${data}`);\n});\n\nninjaProcess.on('close', (code) => {\n  console.log(`Ninja process exited with code ${code}`);\n  if (code !== 0) {\n    console.error('Ninja execution failed. Check stderr for details.');\n  }\n});\n","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The 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.","severity":"breaking","affected_versions":">=0.1.0"},{"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.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Evaluate alternatives for managing the Ninja build system in your project that are actively maintained and provide a current version of Ninja.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"Global 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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`.","error":"node_modules/ninja-build/bin/ninja: No such file or directory"},{"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.","cause":"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.","error":"sh: 1: bash: not found"},{"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.","cause":"Attempting to `require()` or `import` the package or its binary directly as a standard JavaScript module, which it is not.","error":"Error: Cannot find module 'ninja-build' or 'ninja-build/bin/ninja'"}],"ecosystem":"npm"}