{"id":12887,"library":"bin-build","title":"Binary Build Utility","description":"The `bin-build` package, currently at version 3.0.0 and last updated approximately nine years ago (around 2017), provides a JavaScript API for programmatically compiling external software from source code. It simplifies the process of downloading, extracting, and executing a sequence of shell commands (e.g., `./configure`, `make`, `make install`) to build binaries from tarball archives fetched from URLs or local files, or directly from source within a specified directory. This utility is valuable for Node.js projects that need to integrate or manage native dependencies or command-line tools as part of their build or installation workflows. Its main advantage lies in abstracting the common compilation patterns and handling archive extraction, offering a more structured approach than direct `child_process` execution. Given its age and lack of recent updates, it appears to be in a maintenance-only state, with no active development.","status":"maintenance","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/kevva/bin-build","tags":["javascript","binary","build","make"],"install":[{"cmd":"npm install bin-build","lang":"bash","label":"npm"},{"cmd":"yarn add bin-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add bin-build","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library primarily uses CommonJS `require()` syntax. Direct ESM `import` is not natively supported without a bundler, given its last update was prior to widespread Node.js ESM adoption.","wrong":"import binBuild from 'bin-build';","symbol":"binBuild","correct":"const binBuild = require('bin-build');"},{"note":"`url` is a method of the main `binBuild` object, not a named export. Ensure the entire `binBuild` object is imported.","wrong":"import { url } from 'bin-build';","symbol":"binBuild.url","correct":"const binBuild = require('bin-build');\nbinBuild.url('...', [...]);"},{"note":"`file` is a method of the main `binBuild` object, not a named export. Ensure the entire `binBuild` object is imported.","wrong":"import { file } from 'bin-build';","symbol":"binBuild.file","correct":"const binBuild = require('bin-build');\nbinBuild.file('...', [...]);"}],"quickstart":{"code":"const binBuild = require('bin-build');\nconst path = require('path');\nconst fs = require('fs');\n\n// Example: Building gifsicle from a URL\nconst gifsicleUrl = 'http://www.lcdf.org/gifsicle/gifsicle-1.80.tar.gz';\nconst buildCommands = [\n  './configure --disable-gifview --disable-gifdiff',\n  'make install'\n];\n\nconst outputDir = path.join(__dirname, 'built-binaries');\nif (!fs.existsSync(outputDir)) {\n  fs.mkdirSync(outputDir);\n}\n\nconsole.log(`Attempting to build gifsicle from: ${gifsicleUrl}`);\nbinBuild.url(gifsicleUrl, buildCommands, { cwd: outputDir })\n  .then(() => {\n    console.log('gifsicle built successfully in ' + outputDir);\n  })\n  .catch(error => {\n    console.error('Failed to build gifsicle:', error.message);\n    console.error('Ensure build tools (like make, configure, tar) are installed and accessible.');\n  });\n\n// To run this, you would typically need 'tar', 'make', and a C compiler installed on your system.","lang":"javascript","description":"Demonstrates downloading a tarball from a URL, extracting it, and running a series of build commands to compile a binary into a specified output directory."},"warnings":[{"fix":"Ensure that necessary build tools (e.g., `build-essential` on Debian/Ubuntu, Xcode Command Line Tools on macOS, MSYS2/MinGW on Windows) are installed in the deployment environment.","message":"bin-build relies heavily on external system dependencies such as `tar`, `make`, `configure`, and a C/C++ compiler. These tools must be installed and accessible in the system's PATH where the Node.js process is running. This can lead to cross-platform compatibility issues or failures in environments without these development tools.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Carefully audit the package's dependencies and functionality. Consider alternatives for new projects or implement robust error handling and monitoring for existing applications. Evaluate the security implications of running arbitrary commands within your build process.","message":"The package was last published 9 years ago (around 2017) and is effectively unmaintained. This means it may not receive updates for new Node.js versions, security vulnerabilities, or modern JavaScript features (like native ESM). Using unmaintained software can pose security risks and lead to compatibility issues with newer ecosystems.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Only use `bin-build` with trusted source URLs and thoroughly vetted build commands. Implement strict input validation if any part of the URL or commands is user-controlled. Consider running builds in isolated, disposable environments (e.g., Docker containers) with minimal privileges.","message":"When using `binBuild.url()` or `binBuild.file()` with arbitrary commands, the package executes shell commands provided as input. If the source URL or commands are untrusted or compromised, this could lead to arbitrary code execution vulnerabilities (supply chain attacks) in your build environment.","severity":"security","affected_versions":">=1.0.0"},{"fix":"For ESM projects, use `const binBuild = require('bin-build');` or `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const binBuild = require('bin-build');`.","message":"The package is CommonJS-only (`require`). It does not provide native ECMAScript Module (ESM) exports. Attempting to `import` it directly in an ESM context will result in errors unless a bundler or transpiler is used, or dynamic `import()` with `createRequire` is employed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install `tar` on the system (e.g., `sudo apt-get install tar` on Linux, comes with macOS). Verify the archive URL/path is correct and the file is not corrupted.","cause":"The `tar` utility is not installed or not found in the system's PATH, or the archive file is corrupted/malformed.","error":"Error: Command failed: tar -xzf /tmp/some-archive.tar.gz ... (or similar error with 'tar')"},{"fix":"Ensure all necessary build tools and libraries are installed for the target binary (e.g., `build-essential` package on Debian/Ubuntu). Consult the upstream project's documentation for specific build requirements.","cause":"The build command (e.g., `./configure`, `make`) failed because required development tools (compilers, libraries) are missing or configuration steps were incorrect.","error":"Error: Command failed: ./configure ... (or similar error with 'make', 'gcc', etc.)"},{"fix":"Check for typos in the URL. Verify network connectivity and DNS resolution. Ensure there are no firewall rules blocking the request.","cause":"The host name in the provided URL could not be resolved (DNS error), or there's a network connectivity issue preventing the download.","error":"Error: getaddrinfo ENOTFOUND www.example.com (for binBuild.url)"},{"fix":"Ensure `const binBuild = require('bin-build');` is used in a CommonJS context. If in ESM, consider `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const binBuild = require('bin-build');`.","cause":"The `binBuild` object was imported incorrectly or `require('bin-build')` returned an unexpected value (e.g., in an ESM context without proper interoperability).","error":"TypeError: binBuild.url is not a function (or .file, .directory)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}