Registry / serialization / os-browserify

os-browserify

JSON →
library0.3.0jsnpmunverified

The `os-browserify` package provides a browser-compatible shim for Node.js's native `os` module, allowing CommonJS `require('os')` calls to function in web browsers when bundled with Browserify. Its current stable version is 0.3.0, last published in April 2017, indicating an effectively abandoned release cadence. This package serves as a direct polyfill for many `os` functions, adapting them to a browser environment or providing sensible defaults or stubs where native browser APIs cannot replicate Node.js functionality. It differentiates itself by tightly integrating with the Browserify bundling ecosystem, automatically replacing the Node.js `os` core module during the bundling process, making it transparent to applications originally written for Node.js.

npm install os-browserify
INSTALL
IMPORT
SIG · OS-BROWSERIFY
O
os-browserify
serializationjavascriptv0.3.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

os
const os = require('os');
This package is a Browserify shim. Browserify automatically replaces Node.js's `os` core module with this browser-compatible version when `require('os')` is encountered in your source code. You typically do not `require('os-browserify')` directly.
os.platform
console.log(os.platform());
import { platform } from 'os';
Functions are accessed as properties of the `os` object. ESM imports are not directly supported by this CommonJS-based shim.

Demonstrates how to use various Node.js `os` module functions in a browser environment by bundling with Browserify.

/* file: main.js */ const os = require('os'); console.log('--- os-browserify demonstration ---'); console.log('OS Type:', os.type()); console.log('OS Platform:', os.platform()); console.log('OS Release:', os.release()); console.log('OS Arch:', os.arch()); console.log('OS Uptime (seconds):', os.uptime()); console.log('OS Total Memory (bytes):', os.totalmem()); console.log('OS Free Memory (bytes):', os.freemem()); console.log('OS CPU Count:', os.cpus()?.length || 'N/A'); console.log('OS Network Interfaces:', os.networkInterfaces()); /* To run this: */ /* 1. npm init -y && npm install os-browserify browserify */ /* 2. browserify main.js -o bundle.js */ /* 3. Create an HTML file (e.g., index.html): */ /* <script src="bundle.js"></script> */ /* 4. Open index.html in a browser and check console. */
Debug
Known issues
deprecatedThe `os-browserify` package has not been updated in over 9 years, with its last publish in April 2017. While it continues to function for its intended purpose with Browserify, its lack of maintenance means it may not receive updates for new Node.js `os` features or security patches.
fix
Consider alternatives or modern bundlers that may offer better shimming or tree-shaking for browser environments, such as Webpack with its built-in `os` polyfills or custom solutions for newer projects.
affects: 0.3.0
gotchaThis package is tightly coupled with Browserify. It is designed to be a shim that Browserify automatically injects when `require('os')` is used. It is generally not intended for direct use with other bundlers like Webpack, Rollup, or Vite, which have their own mechanisms for handling Node.js core modules.
fix
Ensure you are using Browserify as your module bundler if relying on this package. For other bundlers, consult their documentation on how they handle Node.js core modules (e.g., Webpack's `node` polyfills configuration).
affects: >=0.1.0
gotchaNot all Node.js `os` module functions can be fully replicated or provide meaningful data in a browser environment. Some functions may return generic or stubbed values (e.g., `os.uptime()` might return 0 or a browser-specific timestamp), or might be no-ops.
fix
Always test the specific `os` functions you intend to use in the browser to confirm they provide the expected behavior and data. Review the `os-browserify` source code or documentation for details on specific function implementations.
affects: >=0.1.0
Errors
Common errors & fixes
Uncaught ReferenceError: require is not defined
Attempting to use `require('os')` directly in a browser without a CommonJS bundler like Browserify processing the code.
fix
Bundle your JavaScript code with Browserify, which will replace `require('os')` with the `os-browserify` shim and provide the `require` function to your browser code. Example: `browserify main.js -o bundle.js`.
Uncaught ReferenceError: process is not defined
While `os-browserify` shims the `os` module, some `os` functions (or other dependencies) might indirectly rely on Node.js's global `process` object, which is not available in browsers by default.
fix
Browserify automatically shims `process` if it detects its use. Ensure your Browserify setup is correct and consider explicitly adding a `process` shim if issues persist, though this is usually handled transparently by Browserify itself.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
os-browserify — npm install os-browserify · libregistry