A Rollup/Vite plugin that automatically marks Node.js built-in modules and npm dependencies (dependencies, peerDependencies, optionalDependencies, or devDependencies) as external in your bundle configuration. Version 9.0.1 is the latest stable release, released monthly, requiring Node.js >= 24 and Rollup >= 4 or Vite >= 5. It is zero-dependency, lightweight (<10 kB), and supports monorepos and all package managers. Compared to alternatives like rollup-plugin-auto-external, it offers finer-grained control over which dependency categories to externalize and includes options for handling the node: prefix on builtins.
npm install rollup-plugin-node-externalsVerified import paths — ran on the pinned version, not inferred.
Basic Rollup config using nodeExternals to externalize Node builtins and runtime dependencies, excluding a local module from externalization.
Upgrade to Rollup 4+ and Node.js 24+.
If using `builtinsPrefix: false`, it now strips the prefix (equivalent to 'strip'). Use `builtinsPrefix: 'ignore'` to ignore prefix entirely.
Remove async/await from plugin creation; revert to synchronous factory.
Use `path.resolve(__dirname, 'package.json')` or absolute paths to the package.json file.
Use Vite's `apply: 'build'` property in the plugin options or manually check the environment.
Replace require() with import: use `import nodeExternals from 'rollup-plugin-node-externals'` and configure your project for ESM (e.g., add "type": "module" in package.json).
Use one of the valid values: 'add' (or true), 'strip' (or false), or 'ignore'.
Provide an absolute path to the actual package.json file: `packagePath: path.resolve(__dirname, 'package.json')`.
Set `output.format` (e.g., 'cjs', 'esm', 'iife') in your Rollup config.
No dependency data recorded yet.