constants-browserify
Node's built-in constants module ported to a static JSON file so Browserify can bundle it for the browser.
Repository Health
Technical Analysis
constants-browserify is a tiny shim that re-exports Node.js’s native constants module (file-mode bits, signal codes, errno values, and other OS-level flags) as a plain JSON file, so code written for Node can be bundled with Browserify without hitting a missing built-in module.
It exists purely to satisfy the require('constants') calls that other Node-oriented packages make when they get pulled into a browser bundle. Browserify’s module resolution maps the constants core module to this package via its browser field aliasing, so downstream libraries continue to work unmodified in client-side code.
What You Get
- A JSON object containing the full set of Node
constantsmodule values (O_RDONLY, S_IFDIR, SIGKILL, and other file-mode/signal/errno flags) captured at build time - Drop-in compatibility with the CLI (
browserify -r constants:constants-browserify script.js) or the programmatic Browserify API (.require('constants-browserify', { expose: 'constants' })) - Zero runtime dependencies and no code to execute — the whole package is a generated data file
- A regeneration script (
build.sh) that re-dumps the current Node runtime’sconstantsmodule back intoconstants.json
Common Use Cases
- Bundling older Node libraries (crypto, fs, or zlib wrappers) into browser builds where they transitively
require('constants') - Supplying Browserify’s automatic core-module shimming for
constantswhen building isomorphic JavaScript - Acting as a dependency of other browser shims (like
crypto-browserify) that themselves need constant values ported from Node - One-off regeneration of the constants snapshot against a newer Node version via
build.shbefore publishing an update
Under The Hood
Architecture
The entire package is a single generated data file: constants.json is the main entry, produced by running node -pe 'JSON.stringify(require("constants"), null, " ")' and redirecting the output to disk via build.sh. There is no runtime logic, no exported function, and no dependency graph — require('constants-browserify') simply resolves to a plain object literal, and Browserify’s browser field aliasing is what makes that object stand in for Node’s native constants module inside a client bundle.
Tech Stack
The package has no dependencies ("dependencies": {} in package.json) and targets the CommonJS/Browserify module system rather than ESM or a bundler-native browser field convention. The only tooling artifact is the one-line build.sh shell script that re-runs the dump against whatever Node binary is on PATH.
Code Quality
The single test (test.js) asserts, via Node’s assert.deepEqual, that the checked-in constants.json matches the live require('constants') output of the Node version running the test — a regression guard against the snapshot drifting from upstream Node, but it also means the test’s own correctness is tied to the CI Node version. There are no type definitions, no linter configuration, and no CI workflow files in the repository.
What Makes It Unique
Unlike most npm packages, this one carries no original logic at all — its value is entirely in being an unglamorous but load-bearing compatibility shim inside the Browserify ecosystem, one of the small utility packages other browser-shim libraries (like crypto-browserify) depend on to keep older Node code working unmodified in the browser.
Used by 4 apps in this directory
Bun
Developer Tools
An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.
CodeSandbox
Code Editors · Developer Tools
Instantly ready browser-based IDE that runs full npm dependency resolution and transpilation entirely client-side, with no server needed.
hoodik
File Storage · Security
Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support
Joplin
Note Taking
The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.