Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
node-libs-browser
Advanced tools
Package description
The node-libs-browser package is a collection of browser-friendly versions of Node.js core modules. It allows developers to use Node.js-style modules in the browser, providing shims and polyfills for Node.js core modules that do not have direct equivalents in the browser environment. This package is particularly useful for bundling applications with webpack, which uses it to simulate a Node.js environment in the browser.
Buffer
Provides a Buffer class that can be used for binary data manipulation in the browser, similar to Node.js's Buffer module.
var Buffer = require('buffer/').Buffer;
var buf = Buffer.from('hello world', 'ascii');
console.log(buf.toString('hex'));
Events
Implements the EventEmitter class to enable event-driven architecture in the browser, mimicking Node.js's events module.
var EventEmitter = require('events/').EventEmitter;
var emitter = new EventEmitter();
emitter.on('event', function(message) {
console.log(message);
});
emitter.emit('event', 'Hello world!');
Path
Provides utilities for file path operations, similar to Node.js's path module, but adapted for the browser.
var path = require('path-browserify');
console.log(path.basename('/foo/bar/baz/asdf/quux.html'));
Browserify lets you require('modules') in the browser by bundling up all of your dependencies. It's similar to node-libs-browser in that it allows Node.js code to run in the browser, but it works at the bundling level, transforming Node.js modules into browser-compatible scripts.
This package is used with webpack to automatically exclude node modules. It's related to node-libs-browser in the context of building for the browser, but instead of providing browser versions of Node.js modules, it helps to avoid bundling them altogether.
A port of Node.js's crypto module to the browser. It offers similar functionality to one aspect of node-libs-browser, focusing specifically on cryptographic functions.
Readme
The node core libs for in-browser usage.
NOTE: This library is deprecated and won't accept Pull Requests that include Breaking Changes or new Features. Only bugfixes are accepted.
Exports a hash [object] of absolute paths to each lib, keyed by lib names. Modules without browser replacements are null
.
Some modules have mocks in the mock
directory. These are replacements with minimal functionality.
lib name | browser implementation | mock implementation |
---|---|---|
assert | defunctzombie/commonjs-assert | --- |
buffer | feross/buffer | buffer.js |
child_process | --- | --- |
cluster | --- | --- |
console | Raynos/console-browserify | console.js |
constants | juliangruber/constants-browserify | --- |
crypto | crypto-browserify/crypto-browserify | --- |
dgram | --- | --- |
dns | --- | dns.js |
domain | bevry/domain-browser | --- |
events | Gozala/events | --- |
fs | --- | --- |
http | jhiesey/stream-http | --- |
https | substack/https-browserify | --- |
module | --- | --- |
net | --- | net.js |
os | CoderPuppy/os-browserify | --- |
path | substack/path-browserify | --- |
process | shtylman/node-process | process.js |
punycode | bestiejs/punycode.js | --- |
querystring | mike-spainhower/querystring | --- |
readline | --- | --- |
repl | --- | --- |
stream | substack/stream-browserify | --- |
string_decoder | rvagg/string_decoder | --- |
sys | defunctzombie/node-util | --- |
timers | jryans/timers-browserify | --- |
tls | --- | tls.js |
tty | substack/tty-browserify | tty.js |
url | defunctzombie/node-url | --- |
util | defunctzombie/node-util | --- |
vm | substack/vm-browserify | --- |
zlib | devongovett/browserify-zlib | --- |
buffer
The current buffer
implementation uses feross/buffer@4.x because feross/buffer@5.x relies on typed arrays.
This will be dropped as soon as IE9 is not a typical browser target anymore.
punycode
The current punycode
implementation uses bestiejs/punycode.js@1.x because bestiejs/punycode.js@2.x requires modern JS engines that understand const
and let
.
It will be removed someday since it has already been deprecated from the node API.
MIT
FAQs
The node core libs for in browser usage.
The npm package node-libs-browser receives a total of 5,784,634 weekly downloads. As such, node-libs-browser popularity was classified as popular.
We found that node-libs-browser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.