build-number-generator is a utility that creates unique, human-readable build numbers for software projects. These nine-digit integers encode the build date (YYMMDD) and a count of two-minute intervals after midnight (CCC), ensuring uniqueness for builds at least two minutes apart. The current stable version is 3.0.0, released on 2025-06-26. The package offers both a command-line interface and an API for programmatic use in Node.js, Deno, and web browsers, supporting ESM, CJS, and UMD formats. Key differentiators include its no-dependency footprint, tiny size, and the ability to infer the build time directly from the number without external storage, making it suitable for CI/CD environments. It ships with full TypeScript types.
npm install build-number-generatorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates generating a new build number, combining it with a product version, and then parsing a build number back into a human-readable date. It also shows error handling for invalid build numbers.
Ensure your project runs on Node.js 18 or newer. If you must use older Node.js versions, consider pinning to `build-number-generator@^2.0.0` or `^1.0.0` depending on your specific Node.js version requirements (e.g., v1.x for Node.js < 14.8).
Upgrade your Node.js environment to at least version 14.8, or preferably 16+. If using Node.js < 14.8, you must stick to `build-number-generator@^1.0.0`.
For CLI usage, ensure global installation or verify that your local `node_modules/.bin` symlinks are correctly resolving. For programmatic CJS usage, stick to named exports or use ESM where possible.
If experiencing TypeScript errors with `build-number-generator@2.x`, upgrade to `build-number-generator@^2.0.4` or later to ensure correct type definitions are included and referenced in `package.json` exports.
Factor this design choice into your versioning strategy. If sub-two-minute uniqueness is critical, append an additional unique identifier (e.g., commit hash, incrementing counter) to the generated build number, or ensure builds are spaced out.
Ensure the package is installed (`npm install build-number-generator`). If using Node.js < 14.8, you must use version 1.x. For Node.js >=18, use version 3.x and ensure you're using `import` statements for ESM.
Use named ESM imports: `import { generate } from 'build-number-generator';`. If you are stuck on an older Node.js version requiring CJS, verify `package.json` `exports` or ensure you are using a compatible package version (e.g., v1.x).Always wrap calls to `parse()` in a `try...catch` block, or validate the build number first using `validate()` before parsing, especially if the input is user-supplied or external.
Ensure the input string is exactly 9 digits long and conforms to the YYMMDDCCC pattern (e.g., `240419123` for April 19, 2024). This error also occurs if the numeric value exceeds `235929999`.
No dependency data recorded yet.