Registry / os-shim

os-shim

JSON →
library0.1.3jsnpmunverified

The `os-shim` package provides a compatibility layer for the native Node.js `os` module API, backporting features that became standard in Node.js 0.10.x to much older versions, specifically 0.4.x and 0.8.x. It shims functions like `os.tmpdir()`, `os.endianness()`, `os.platform()`, `os.arch()`, and the `os.EOL` constant, which were either missing or had differing behaviors in those legacy environments. The package is currently at version 0.1.3 (last updated circa 2013) and has an abandoned release cadence, meaning it is no longer actively maintained. Its primary differentiator was enabling consistent `os` module usage across deeply antiquated Node.js runtimes where standard `os` module features were inconsistent or absent.

npm install os-shim
INSTALL
IMPORT
SIG · OS-SHIM
O
os-shim
javascriptv0.1.3
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-shim')
import os from 'os-shim'
This package is designed for CommonJS in Node.js versions < 0.10.x. ESM `import` syntax is not applicable to its target environments.
os.tmpdir
os.tmpdir()
Access methods like `tmpdir()` directly from the `os` object returned by `require('os-shim')`.
os.EOL
os.EOL
Access constants like `EOL` directly from the `os` object returned by `require('os-shim')`.

Demonstrates how to use the `os-shim` package to access various operating system properties like temporary directory, endianness, EOL, platform, and architecture, highlighting its role in legacy environments.

const osShim = require('os-shim'); console.log('Using os-shim to access OS module properties:'); console.log('-------------------------------------------'); // Shimmed methods/properties that were missing in old Node.js versions: console.log('Temporary directory:', osShim.tmpdir()); console.log('Endianness:', osShim.endianness()); console.log('End-of-Line:', JSON.stringify(osShim.EOL)); console.log('Platform:', osShim.platform()); console.log('Architecture:', osShim.arch()); // Original 'os' module for comparison (if available in the current environment) // Note: This shim is primarily for environments where some of these might be missing. try { const nativeOs = require('os'); console.log('\n--- Comparison with native os module (if available) ---'); console.log('Native Temporary directory:', nativeOs.tmpdir()); console.log('Native Endianness:', nativeOs.endianness()); console.log('Native End-of-Line:', JSON.stringify(nativeOs.EOL)); console.log('Native Platform:', nativeOs.platform()); console.log('Native Architecture:', nativeOs.arch()); } catch (e) { console.log('\nNative \'os\' module might be partially or fully unavailable in this environment or cannot be loaded.'); }
Debug
Known issues
breakingThis package is designed exclusively for Node.js versions 0.4.x - 0.8.x, which are long past their End-of-Life (EOL) and contain numerous known security vulnerabilities. Using this package effectively requires operating in a highly insecure environment.
fix
Upgrade to a currently supported Node.js version. If legacy code truly requires specific `os` module behavior, backport the minimal polyfill directly or rewrite the affected logic to use modern APIs.
affects: *
gotchaThe `os-shim` package provides no value in modern Node.js environments (typically v10+), as the native `os` module already includes all the shimmed functionality and much more. Using it unnecessarily adds a layer of indirection.
fix
Remove `os-shim` from your project and directly use the native `os` module provided by modern Node.js runtimes. For example, replace `require('os-shim')` with `require('os')`.
affects: >=1.0.0
deprecatedThe package is unmaintained, with the last meaningful update in 2013 and an unaddressed "To Do" list, indicating it has been abandoned by its maintainers.
fix
Do not introduce this package into new projects. For existing projects, evaluate its necessity and consider migrating to modern Node.js APIs or custom, targeted polyfills if absolutely necessary for ancient Node.js targets.
affects: *
Errors
Common errors & fixes
TypeError: osShim.someNewMethod is not a function
The `os-shim` package only backports a very limited set of `os` module APIs that were specifically missing in Node.js 0.4.x - 0.8.x.
fix
This shim does not provide newer `os` module APIs (e.g., `os.cpus()`, `os.networkInterfaces()` in their modern forms). Use the native `os` module for comprehensive or modern API access, or implement a specific polyfill if truly targeting ancient Node.js environments.
ReferenceError: require is not defined
This package is a Node.js-specific shim designed for server-side environments and is not intended for browser environments.
fix
Do not attempt to use `os-shim` in a browser. For browser-compatible OS-like functionality, use dedicated browser utility libraries or web APIs.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

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