node-libs-browser is a utility package providing browser-compatible polyfills and mock implementations for a subset of Node.js core modules. Its primary purpose is to enable bundlers like Webpack to resolve `require('fs')` or `require('buffer')` in browser environments, substituting Node.js-specific APIs with browser-friendly alternatives. The current stable version is 2.2.1. This library is officially deprecated, meaning it will not accept new features or breaking changes; only bugfixes. Its release cadence is effectively stalled, with the last major update several years ago. While historically critical for enabling Node.js code in the browser, modern development often favors more granular polyfills, conditional imports, or alternatives like `node-stdlib-browser` that are actively maintained and offer newer implementations and ESM support, addressing issues like `punycode` deprecation in newer Node.js versions.
npm install node-libs-browserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import `node-libs-browser` and iterate through the provided Node.js core library mappings, showing which modules have browser implementations or mocks.
Migrate to actively maintained alternatives or ensure your bundler configuration handles Node.js polyfills explicitly without relying solely on this package.
If modern `Buffer` API features are required and IE9 compatibility is not a concern, you may need to explicitly configure your bundler to use a newer `buffer` polyfill or an alternative package.
For projects running on newer Node.js versions, address `punycode` deprecation warnings by updating dependencies that might be transitively relying on it, or using an explicit userland `punycode.js` package and configuring bundler aliases.
Refactor application code to avoid Node.js-specific modules in browser contexts, use conditional imports for environment-specific code, or explicitly mock/polyfill unavailable modules if essential.
Ensure `node-libs-browser` is configured via your bundler's options (e.g., Webpack's `resolve.alias` or `node` options) rather than being manually imported and consumed in application code. Consider bundler-specific plugins or alternatives that provide more opinionated or modern approaches to polyfilling.
Review the usage of Node.js core modules. For modules with `null` implementations, refactor the code to avoid them in browser contexts, or use a specific, actively maintained browser polyfill if available and appropriate, configuring your bundler to alias it.
Ensure your bundler's configuration (e.g., Webpack's `NodeSourcePlugin`, `node` option, or `ProvidePlugin`) correctly sets up the `process` polyfill. Verify that `node-libs-browser` (or its `process` sub-dependency) is included and active.
If your application requires modern `Buffer` APIs, you must explicitly configure your bundler to use a newer `buffer` polyfill (e.g., `feross/buffer@5.x` or later) and accept potential compatibility issues with very old browsers like IE9.
Run `npm ls punycode` to identify the direct or transitive dependency. If `node-libs-browser` is the culprit, consider migrating to a more modern alternative like `node-stdlib-browser` which addresses this, or use bundler `overrides` to force a newer, userland `punycode.js` version.
No dependency data recorded yet.