{"id":17398,"library":"vite-plugin-node-stdlib-browser","title":"Vite Plugin for Node.js Standard Library Browser Polyfills","description":"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.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install vite-plugin-node-stdlib-browser","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-node-stdlib-browser","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-node-stdlib-browser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides the actual Node.js standard library polyfills for the browser environment.","package":"node-stdlib-browser","optional":false},{"reason":"The plugin integrates with the Vite build tool; required for Vite projects.","package":"vite","optional":false}],"imports":[{"note":"The plugin is typically imported as a default export in `vite.config.js`, which is generally an ESM context.","wrong":"const nodePolyfills = require('vite-plugin-node-stdlib-browser')","symbol":"nodePolyfills","correct":"import nodePolyfills from 'vite-plugin-node-stdlib-browser'"},{"note":"Required for defining your Vite configuration, commonly used alongside this plugin.","wrong":"const { defineConfig } = require('vite')","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'"}],"quickstart":{"code":"import { defineConfig } from 'vite'\nimport nodePolyfills from 'vite-plugin-node-stdlib-browser'\n\nexport default defineConfig({\n  plugins: [\n    nodePolyfills()\n  ]\n})","lang":"javascript","description":"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."},"warnings":[{"fix":"Refactor code to avoid `node:` protocol imports. If `node:` protocol support is critical, consider using an alternative plugin like `vite-plugin-node-polyfills`.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"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`.","cause":"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.","error":"ReferenceError: Buffer is not defined"},{"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.","cause":"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`.","error":"Failed to resolve import \"node:fs\" from \"...\""}],"ecosystem":"npm","meta_description":null}