Registry / serialization / node-libs-browser-okam

node-libs-browser-okam

JSON →
library2.2.5jsnpmunverified

This package, `node-libs-browser-okam` (a fork of the original `node-libs-browser`), provides browser-compatible polyfills and mock implementations for a wide range of Node.js core modules such as `buffer`, `process`, `path`, `events`, and `util`. Currently at version `2.2.5`, it is explicitly marked as deprecated and only accepts bug fixes, with no new features or breaking changes planned. Its primary use case is within module bundlers like Webpack to automatically resolve Node.js built-in module imports to browser-compatible alternatives, preventing "module not found" errors in front-end applications. The package exports a JavaScript object where keys are Node.js module names and values are the absolute paths to their respective browser implementations or `null` if no browser-compatible version is available. It relies on older versions of some key dependencies like `buffer` and `punycode` to maintain broader browser compatibility (e.g., IE9).

npm install node-libs-browser-okam
INSTALL
IMPORT
SIG · NODE-LIBS-BROWSER-
N
node-libs-browser-okam
serializationjavascriptv2.2.5
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.

nodeLibs
import nodeLibs from 'node-libs-browser-okam';
import { nodeLibs } from 'node-libs-browser-okam';
The package exports a default object containing paths to browser polyfills. Named imports are incorrect.
nodeLibs
const nodeLibs = require('node-libs-browser-okam');
CommonJS `require` is the most common way to import this package due to its age and common usage in bundler configurations.
bufferPath
const bufferPath = require('node-libs-browser-okam').buffer;
import { buffer } from 'node-libs-browser-okam';
Individual module paths are accessed as properties on the default exported object.

Demonstrates importing the object of Node.js browser libraries and iterating through the available polyfill paths, highlighting how a bundler might resolve a module like 'buffer'.

import nodeLibs from 'node-libs-browser-okam'; console.log('Available Node.js browser libs:'); for (const libName in nodeLibs) { const libPath = nodeLibs[libName]; if (libPath) { console.log(`- ${libName}: ${libPath}`); } else { console.log(`- ${libName}: (No browser implementation available)`); } } // Example: How a bundler might use it to resolve 'buffer' const resolvedBufferPath = nodeLibs.buffer; if (resolvedBufferPath) { console.log(`\nPath to buffer polyfill: ${resolvedBufferPath}`); } else { console.log('\nBuffer polyfill not found.'); } // This package is primarily used by bundlers like Webpack for automatic aliasing. // For direct usage, you would typically configure a bundler to use these paths.
Debug
Known issues
deprecatedThe `node-libs-browser` project is officially deprecated and only accepts bug fixes. No new features or breaking changes will be introduced. Users should consider modern alternatives for polyfilling Node.js built-ins in browser environments, or ensure their bundler explicitly handles these.
fix
Review your project's dependency on `node-libs-browser-okam` and explore more actively maintained polyfills or ensure your bundler (e.g., Webpack 5+) has native fallbacks or custom resolutions configured.
affects: >=2.0.0
gotchaThe `buffer` implementation uses `feross/buffer@4.x` instead of the newer `5.x` version. This is due to a deliberate choice to support older browsers (like IE9) by avoiding reliance on typed arrays. Consequently, `Buffer.from()` and other modern `Buffer` static methods are not available.
fix
If your code requires `Buffer.from()` or other modern `Buffer` APIs, you may need to explicitly import a newer `buffer` polyfill or use an alternative method like `new Buffer()` (which is deprecated in Node.js itself but works with this polyfill).
affects: >=2.0.0
gotchaThe `punycode` implementation uses `bestiejs/punycode.js@1.x`, which requires older JavaScript engines. This means it may not be compatible with newer `punycode` APIs or expectations of modern JavaScript syntax.
fix
If specific modern `punycode` functionalities are required, consider importing a more up-to-date `punycode` polyfill directly rather than relying on the one provided by `node-libs-browser-okam`.
affects: >=2.0.0
gotchaMany Node.js core modules, such as `child_process`, `cluster`, `dgram`, `fs`, `module`, `net`, `readline`, `repl`, `tls`, do not have browser-compatible implementations within this package. Their entries in the exported object are `null`.
fix
Avoid importing these Node.js-specific modules in browser code. If their functionality is critical, you must find entirely different browser-native solutions or refactor your application logic.
affects: >=2.0.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'fs' in '/path/to/your/project'
Attempting to import a Node.js core module (like `fs`, `net`, `child_process`) that `node-libs-browser-okam` does not provide a browser polyfill for (its entry in the exported object is `null`).
fix
Remove the problematic import from your browser-side code. These modules are fundamentally tied to the Node.js environment and typically cannot be replicated in a browser. Re-evaluate your architecture if such functionality is critical for the client.
TypeError: Buffer.from is not a function
Code expects the `Buffer.from()` static method, but `node-libs-browser-okam` uses an older `feross/buffer@4.x` polyfill which predates this API, primarily supporting `new Buffer()`.
fix
Refactor your code to use `new Buffer(array)` or `new Buffer(string, encoding)` instead of `Buffer.from()`. Alternatively, you can configure your bundler to alias `buffer` to a different, more modern polyfill that supports `Buffer.from()`.
ReferenceError: process is not defined
The global `process` object, expected by some Node.js modules, is not correctly aliased to its browser polyfill by the bundler, or accessed in a context where the polyfill isn't available.
fix
Ensure your bundler (e.g., Webpack, Rollup, Browserify) has `node-libs-browser-okam` or a similar polyfill configured to correctly alias the global `process` object. For Webpack, this often involves configuring `resolve.fallback` or `ProvidePlugin` for older versions.
Uncaught TypeError: crypto.createHash is not a function
While `crypto` has a browser polyfill, it may not implement all functions available in Node.js's native `crypto` module, leading to runtime errors for unsupported APIs.
fix
Review the specific `crypto` function being called. If it's not implemented, you'll need to find a dedicated browser-compatible cryptography library that provides the required functionality, or refactor your code to avoid the unsupported API.
Upgrade
Version history
2.2.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
node-libs-browser-okam — npm install node-libs-browser-okam · libregistry