{"id":15418,"library":"build-utils","title":"Build Utilities Collection","description":"build-utils is a JavaScript library offering a collection of utility functions primarily designed for build scripts. It encapsulates common operations across file system manipulation (`fs`), process execution (`process`), configuration updates (`config`), object transformations (`object`), and command-line interface (`cli`) helpers. The current stable version is 2.0.12, but it was last published on npm approximately eight years ago (August 2018). Due to its age, it primarily uses the CommonJS module system and is not actively maintained, meaning there are no new features, bug fixes, or security updates. It serves as a straightforward, albeit outdated, toolkit for basic automation tasks, lacking the modern features or dual ESM/CJS support found in contemporary alternatives.","status":"maintenance","version":"2.0.12","language":"javascript","source_language":"en","source_url":"https://github.com/oricalvo/build-utils","tags":["javascript"],"install":[{"cmd":"npm install build-utils","lang":"bash","label":"npm"},{"cmd":"yarn add build-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add build-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only due to its last publish date in 2018. ESM import syntax will result in a runtime error.","wrong":"import { createDirectory } from 'build-utils';","symbol":"createDirectory","correct":"const { createDirectory } = require('build-utils');"},{"note":"Functions are often grouped under namespaces like `process`. Direct ESM imports are not supported.","wrong":"import { process } from 'build-utils'; const { spawn } = process;","symbol":"spawn","correct":"const { spawn } = require('build-utils').process;"},{"note":"Individual utilities are exposed via their category namespace (e.g., `object.deepAssign`). Referencing sub-paths or default imports will not work.","wrong":"import deepAssign from 'build-utils/object';","symbol":"deepAssign","correct":"const { deepAssign } = require('build-utils').object;"}],"quickstart":{"code":"const { createDirectory, writeFile, deleteDirectory } = require('build-utils').fs;\nconst { exec } = require('build-utils').process;\nconst path = require('path');\n\nasync function runBuildProcess() {\n  const tempDir = path.join(__dirname, 'temp-output');\n  const tempFile = path.join(tempDir, 'artifact.txt');\n\n  console.log(`Creating directory: ${tempDir}`);\n  await createDirectory(tempDir);\n  console.log('Directory created.');\n\n  console.log(`Writing file: ${tempFile}`);\n  await writeFile(tempFile, 'This is a build artifact generated by build-utils.\\nHello, World!');\n  console.log('File written.');\n\n  console.log('Executing a command: ls');\n  try {\n    const { stdout, stderr } = await exec('ls -l ' + tempDir);\n    console.log('Stdout:', stdout);\n    if (stderr) console.error('Stderr:', stderr);\n  } catch (error) {\n    console.error('Error executing command:', error.message);\n  }\n\n  console.log(`Cleaning up directory: ${tempDir}`);\n  await deleteDirectory(tempDir);\n  console.log('Cleanup complete.');\n}\n\nrunBuildProcess().catch(console.error);\n","lang":"javascript","description":"This quickstart demonstrates basic file system operations (create, write, delete) and process execution using `build-utils` in a CommonJS Node.js environment."},"warnings":[{"fix":"Evaluate actively maintained build utility libraries or implement functionalities using Node.js's native `fs`, `child_process`, and `path` modules.","message":"The `build-utils` package was last published in August 2018. It is unmaintained, which means there will be no new features, bug fixes, or security updates. Users should consider migrating to actively maintained alternatives for critical projects.","severity":"breaking","affected_versions":">=2.0.12"},{"fix":"Ensure your project is configured for CommonJS, or use `require()` statements within a CJS-compatible file. For ESM projects, consider modern dual-module libraries.","message":"This package is exclusively designed for CommonJS (CJS) environments and does not support ECMAScript Modules (ESM) syntax. Attempting to use `import` statements will lead to runtime errors in Node.js ESM projects.","severity":"breaking","affected_versions":">=2.0.12"},{"fix":"Test thoroughly on your target Node.js version. If issues arise, direct replacement with Node.js built-ins or newer libraries is recommended.","message":"Compatibility with newer Node.js versions is uncertain due to the package's age. It may rely on deprecated Node.js APIs or exhibit unexpected behavior with recent runtime changes, potentially leading to instability or subtle bugs.","severity":"gotcha","affected_versions":">=2.0.12"},{"fix":"Verify glob patterns rigorously, especially for complex scenarios. If discrepancies are found, consider using a dedicated and maintained globbing library in conjunction with this package or as a replacement.","message":"The globbing utilities (`copyGlob`, `deleteGlob`, `searchGlob`) might use an outdated or custom glob implementation. This could lead to different behavior compared to modern, widely adopted globbing libraries (e.g., `fast-glob`), affecting pattern matching and file resolution.","severity":"gotcha","affected_versions":">=2.0.12"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Change your file's extension to `.cjs` or ensure your `package.json` specifies `\"type\": \"commonjs\"`. Alternatively, use dynamic `import()` for CJS modules within ESM, but be aware of potential interoperability complexities.","cause":"Attempting to use `require()` in an ECMAScript Module (ESM) context when `build-utils` is a CommonJS-only package.","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Ensure you are correctly accessing utilities under their respective namespaces (e.g., `require('build-utils').fs.createDirectory`). Verify the exact function name and nesting from the package's source or documentation.","cause":"This error typically occurs when trying to destructure a property from `undefined`. It implies that `require('build-utils')` did not return an object with a `fs` property, or `fs` did not have `createDirectory`, likely due to incorrect import path or module resolution issues.","error":"TypeError: Cannot read properties of undefined (reading 'createDirectory')"},{"fix":"Check that the command you are trying to execute (`ls`, `git`, `npm`, etc.) is installed and accessible in the system's PATH environment variable. Provide the full path to the executable if it's not globally available.","cause":"The `exec` or `spawn` utility within `build-utils.process` could not find the specified command in the system's PATH. This is a common operating system error when trying to run an unrecognized executable.","error":"Error: spawn ENOENT"}],"ecosystem":"npm"}