Registry / devops / vite-plugin-node-externals

vite-plugin-node-externals

JSON →
library0.0.1jsnpmunverified

Vite plugin that wraps rollup-plugin-node-externals to automatically externalize Node.js built-in modules and npm dependencies in Vite builds. Version 0.0.1, released in 2021. No active release cadence. The main differentiator is that it fixes Vite's plugin ordering issue by enforcing 'pre' type, allowing rollup-plugin-node-externals to work correctly. However, the author recommends against using it and suggests directly configuring rollup-plugin-node-externals with enforce: 'pre' instead.

npm install vite-plugin-node-externals
INSTALL
IMPORT
SIG · VITE-PLUGIN-NODE-E
V
vite-plugin-node-externals
devopsjavascriptv0.0.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import nodeExternals from 'vite-plugin-node-externals'
const nodeExternals = require('vite-plugin-node-externals')
ESM-only; package has no CJS export.
nodeExternals
import { nodeExternals } from 'vite-plugin-node-externals'
import nodeExternals from 'vite-plugin-node-externals'
Named export also available, but default export is the plugin function.
PluginOptions
import type { PluginOptions } from 'vite-plugin-node-externals'
import { PluginOptions } from 'vite-plugin-node-externals'
TypeScript type import only.

Basic setup to externalize Node builtins and deps in a Vite library build.

// vite.config.js import { defineConfig } from 'vite'; import nodeExternals from 'vite-plugin-node-externals'; export default defineConfig({ plugins: [ nodeExternals(), ], });
Debug
Known issues
deprecatedAuthor recommends not using this package; use rollup-plugin-node-externals directly with enforce: 'pre'.
fix
Replace with rollup-plugin-node-externals and set enforce: 'pre'.
affects: >=0.0.0
breakingDoes not support CommonJS require() – only ES module imports work.
fix
Use import syntax or switch to a CJS-compatible wrapper.
affects: >=0.0.0
gotchaOptions passed to nodeExternals() may not be fully forwarded to rollup-plugin-node-externals due to thin wrapper.
fix
Use rollup-plugin-node-externals directly for full option support.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Must use import to load ES Module: /path/to/vite-plugin-node-externals/index.mjs
Package is ESM-only, but project uses CommonJS require()
fix
Change require() to import() or switch to dynamic import.
TypeError: nodeExternals is not a function
Importing named export 'nodeExternals' from default export
fix
Use import nodeExternals from 'vite-plugin-node-externals' (default) or import { nodeExternals } from '...' (named).
Error: The plugin 'vite-plugin-node-externals' is not compatible with current Vite version
Vite version mismatch; package may not support Vite 3+
fix
Use rollup-plugin-node-externals directly or update vite-plugin-node-externals if available.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
rollup-plugin-node-externalsrequiredCore logic for externalizing Node.js modules and dependencies
Agent activity
8 hits · last 30 days
node
8
Resources
vite-plugin-node-externals — npm install vite-plugin-node-externals · libregistry