Registry / http-networking / vite-plugin-node-stdlib-browser

vite-plugin-node-stdlib-browser

JSON →
library0.2.1jsnpmunverified

vite-plugin-node-stdlib-browser, currently at version 0.2.1, is a Vite plugin designed to integrate `node-stdlib-browser` into Vite projects. Its primary function is to provide browser polyfills for Node.js built-in modules, enabling web applications to run code that implicitly or explicitly relies on these Node.js APIs within a browser environment. The plugin maintains a relatively slow release cadence, typical for a utility plugin that wraps another library, and its current version is still in an early development stage, as indicated by the author's disclaimer regarding limited testing in complex projects. A key differentiator is its explicit design choice to *not* support `node:` protocol imports and to *only* polyfill dependencies, not direct user code. This intentional limitation sets it apart from alternatives like `vite-plugin-node-polyfills`, which does offer `node:` protocol support. Developers should be aware of these architectural decisions when choosing a polyfill solution.

npm install vite-plugin-node-stdlib-browser
INSTALL
IMPORT
SIG · VITE-PLUGIN-NODE-S
V
vite-plugin-node-stdlib-browser
http-networkingjavascriptv0.2.1
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.

nodePolyfills
import nodePolyfills from 'vite-plugin-node-stdlib-browser'
const nodePolyfills = require('vite-plugin-node-stdlib-browser')
The plugin is typically imported as a default export in `vite.config.js`, which is generally an ESM context.
defineConfig
import { defineConfig } from 'vite'
const { defineConfig } = require('vite')
Required for defining your Vite configuration, commonly used alongside this plugin.

This quickstart demonstrates how to configure `vite-plugin-node-stdlib-browser` in your `vite.config.js` to enable Node.js standard library polyfills for your Vite project's browser build. It shows the necessary import and plugin registration.

import { defineConfig } from 'vite' import nodePolyfills from 'vite-plugin-node-stdlib-browser' export default defineConfig({ plugins: [ nodePolyfills() ] })
Debug
Known issues
gotchaThis plugin explicitly does NOT support `node:` protocol imports (e.g., `import fs from 'node:fs'`). If your code or dependencies use this syntax, they will not be polyfilled.
fix
Refactor code to avoid `node:` protocol imports. If `node:` protocol support is critical, consider using an alternative plugin like `vite-plugin-node-polyfills`.
affects: >=0.1.0
gotchaThe plugin is intentionally designed to polyfill Node.js built-in libraries only within your project's *dependencies*, not directly within your user-written application code.
fix
Ensure your application-level code is browser-compatible and avoids direct reliance on Node.js built-ins unless they are provided by a dependency that the plugin is configured to polyfill.
affects: >=0.1.0
gotchaThe plugin's author notes that it has only been tested in 'simple projects.' This implies potential unforeseen issues or instability when integrated into more complex or edge-case Vite configurations.
fix
Thoroughly test your application when integrating this plugin, particularly in production builds or complex setups. Report any encountered issues to the project's GitHub repository to contribute to its stability.
affects: >=0.1.0
Errors
Common errors & fixes
ReferenceError: Buffer is not defined
A browser environment attempted to execute code that relies on Node.js global objects or built-in modules (e.g., `Buffer`, `process`, `global`) without proper polyfilling.
fix
Ensure `vite-plugin-node-stdlib-browser` is correctly installed as a dev dependency and `node-stdlib-browser` as a regular dependency. Verify the plugin is correctly configured and added to the `plugins` array in your `vite.config.js`.
Failed to resolve import "node:fs" from "..."
The application code or a dependency is attempting to use a `node:` protocol import (e.g., `node:fs`, `node:path`), which is explicitly not supported by `vite-plugin-node-stdlib-browser`.
fix
Refactor the code to avoid `node:` protocol imports. If `node:` protocol support is essential for your project, consider using an alternative plugin like `vite-plugin-node-polyfills` which offers this functionality.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
node-stdlib-browserrequiredProvides the actual Node.js standard library polyfills for the browser environment.
viterequiredThe plugin integrates with the Vite build tool; required for Vite projects.
Agent activity
21 hits · last 30 days
node
18
OpenAI (training)
1
Resources
vite-plugin-node-stdlib-browser — npm install vite-plugin-node-stdlib-browser · libregistry