{"id":13724,"library":"os-browserify","title":"OS Module for Browsers (Browserify Shim)","description":"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.","status":"abandoned","version":"0.3.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/CoderPuppy/os-browserify","tags":["javascript"],"install":[{"cmd":"npm install os-browserify","lang":"bash","label":"npm"},{"cmd":"yarn add os-browserify","lang":"bash","label":"yarn"},{"cmd":"pnpm add os-browserify","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","symbol":"os","correct":"const os = require('os');"},{"note":"Functions are accessed as properties of the `os` object. ESM imports are not directly supported by this CommonJS-based shim.","wrong":"import { platform } from 'os';","symbol":"os.platform","correct":"console.log(os.platform());"}],"quickstart":{"code":"/* file: main.js */\nconst os = require('os');\n\nconsole.log('--- os-browserify demonstration ---');\nconsole.log('OS Type:', os.type());\nconsole.log('OS Platform:', os.platform());\nconsole.log('OS Release:', os.release());\nconsole.log('OS Arch:', os.arch());\nconsole.log('OS Uptime (seconds):', os.uptime());\nconsole.log('OS Total Memory (bytes):', os.totalmem());\nconsole.log('OS Free Memory (bytes):', os.freemem());\nconsole.log('OS CPU Count:', os.cpus()?.length || 'N/A');\nconsole.log('OS Network Interfaces:', os.networkInterfaces());\n\n/* To run this: */\n/* 1. npm init -y && npm install os-browserify browserify */\n/* 2. browserify main.js -o bundle.js */\n/* 3. Create an HTML file (e.g., index.html): */\n/*    <script src=\"bundle.js\"></script> */\n/* 4. Open index.html in a browser and check console. */","lang":"javascript","description":"Demonstrates how to use various Node.js `os` module functions in a browser environment by bundling with Browserify."},"warnings":[{"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.","message":"The `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.","severity":"deprecated","affected_versions":"0.3.0"},{"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).","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"Not 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.3.0':43 '2017':48 'abandon':52 'adapt':66 'allow':24 'api':81 'applic':112 'april':47 'automat':97 'browser':4,15,33,70,80 'browser-compat':14 'browserifi':5,10,37,94 'bundl':35,95,106 'cadenc':54 'call':28 'cannot':82 'commonj':25 'compat':16 'core':102 'current':39 'default':75 'differenti':87 'direct':60 'ecosystem':96 'effect':51 'environ':71 'function':30,65,85 'indic':49 'integr':91 'javascript':117 'last':44 'make':108 'mani':63 'modul':2,23,103 'nativ':21,79 'node.js':19,84,100,116 'origin':113 'os':1,9,22,27,64,101 'os-browserifi':8 'packag':11,56 'polyfil':61 'process':107 'provid':12,73 'publish':45 'releas':53 'replac':98 'replic':83 'requir':26 'sensibl':74 'serv':57 'shim':6,17 'stabl':40 'stub':77 'tight':90 'transpar':110 'version':41 'web':32 'written':114","created_at":"2026-04-20T01:55:59.371962+00:00","updated_at":"2026-04-20T01:55:59.371962+00:00","problems":[{"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`.","cause":"Attempting to use `require('os')` directly in a browser without a CommonJS bundler like Browserify processing the code.","error":"Uncaught ReferenceError: require is not defined"},{"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.","cause":"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.","error":"Uncaught ReferenceError: process is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/CoderPuppy/os-browserify","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/os-browserify","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}