Registry / devops / herb-build-utils

herb-build-utils

JSON →
library1.4.5jsnpmunverified

A collection of utility functions for build processes, including file manipulation, path resolution, and environment configuration. Current stable version is 1.4.5 with monthly releases. Provides typed, ESM-first helpers for Node.js build scripts, focusing on simplicity and zero dependencies. Differentiates from similar tools (e.g., shelljs) by offering a modern, promise-based API without CLI overhead.

npm install herb-build-utils
INSTALL
IMPORT
SIG · HERB-BUILD-UTILS
H
herb-build-utils
devopsjavascriptv1.4.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

resolvePath
import { resolvePath } from 'herb-build-utils'
const resolvePath = require('herb-build-utils').resolvePath
Package is ESM-only since v1; no CJS support.
readFile
import { readFile } from 'herb-build-utils'
import readFile from 'herb-build-utils'
`readFile` is a named export, not default.
writeFile
import { writeFile } from 'herb-build-utils'
Standard named export; no require() equivalent.
type ResolveOptions
import type { ResolveOptions } from 'herb-build-utils'
import { ResolveOptions } from 'herb-build-utils'
Use `import type` for type-only imports in TypeScript.

Demonstrates resolving a path, reading JSON, modifying, and writing back using promise-based utilities.

import { resolvePath, readFile, writeFile } from 'herb-build-utils'; const baseDir = process.env.BUILD_DIR ?? './dist'; const filePath = resolvePath(baseDir, 'config.json'); async function updateConfig(key, value) { const content = await readFile(filePath, 'utf-8'); const config = JSON.parse(content); config[key] = value; await writeFile(filePath, JSON.stringify(config, null, 2)); } updateConfig('version', '1.0.0').catch(console.error);
Debug
Known issues
breakingPackage is ESM-only; does not support CommonJS require().
fix
Use `import` syntax and set `"type": "module"` in package.json.
affects: >=1.0.0
gotchaAll functions return promises; forgetting `await` leads to unresolved promises.
fix
Always `await` calls or chain `.then()`.
affects: >=1.0.0
deprecated`readJSON` and `writeJSON` are deprecated in v1.4.0.
fix
Use `readFile` and `writeFile` with `JSON.parse/stringify` instead.
affects: >=1.4.0
Errors
Common errors & fixes
Cannot find module 'herb-build-utils'
Package not installed or missing from dependencies.
fix
Run `npm install herb-build-utils`.
require() of ES Module not supported
Using `require()` on an ESM-only package.
fix
Convert to `import` or use dynamic `import()`.
TypeError: resolvePath is not a function
Incorrect import; possibly default import instead of named.
fix
Use `import { resolvePath } from 'herb-build-utils'`.
Upgrade
Version history
1.4.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
herb-build-utils — npm install herb-build-utils · libregistry