rollup-plugin-node-externals weekly downloads statistics
By Septh · npm · Vite plugins
Automatically declare NodeJS built-in modules and npm dependencies as 'external' in Rollup/Vite config
rollup-plugin-node-externals has 338,051 recorded weekly downloads on npm, an increase of 17.7% over the past 30 days, ranking #446 of 3,247 tracked listings.
About rollup-plugin-node-externals
rollup-plugin-node-externals
A Rollup/Vite plugin that automatically declares NodeJS built-in modules and npm dependencies as external.
- Ultra-lightweight: less than 10 kB download, less than 25 kB unpacked.
- Zero runtime dependencies.
- Works in monorepos.
- Works with all package managers.
Why you need this
<details><summary>(click to read if you're wondering)</summary>By default, Rollup doesn't know a thing about NodeJS, so trying to bundle simple things like import path from 'node:path' in your code results in an Unresolved dependencies warning.
The solution here is quite simple: you must tell Rollup that the node:path module is in fact external. This way, Rollup won't try to bundle it in and rather leave the import statement as is (or translate it to a require() call if bundling for CommonJS).
However, this must be done for each and every NodeJS built-in you happen to use in your program: node:path, node:os, node:fs, node:url, etc., which can quickly become cumbersome when done manually.
So the primary goal of this plugin is simply to automatically declare all NodeJS built-in modules as external. As an added bonus, this plugin will also declare your dependencies (as per your local or monorepo package.json file(s)) as external.
Requirements
- Rollup >= 4 or Vite >= 5
- NodeJS >= 24
Installation
Use your favorite package manager. Mine is npm:
npm install --save-dev rollup-plugin-node-externals
Usage
Import
The plugin is available both as the default export and as a named export:
import nodeExternals from 'rollup-plugin-node-externals'
and
import { nodeExternals } from 'rollup-plugin-node-externals'
will both work.
Options
You generally want to have your runtime dependencies (those that will be imported/required at runtime) listed under dependencies in package.json, and your development dependencies (those that should be bundled in by Rollup/Vite) listed under devDependencies.
If you follow this simple rule, then the default settings are just what you need:
// rollup.config.js / vite.config.js
export default {
...
plugins: [
nodeExternals(),
]
}
This will bundle your devDependencies in while leaving your dependencies, peerDependencies and optionalDependencies external.
Should the defaults not suit your case, here is the full list of options.
import nodeExternals from 'rollup-plugin-node-externals'
export default {
...
plugins: [
nodeExternals({
// Mark NodeJS builtins external. Default: true.
builtins?: boolean
// node: prefix handing for importing NodeJS builtins. Default: 'add'.
builtinsPrefix?: boolean | 'add' | 'strip' | 'ignore'
// The path(s) to your package.json. Default: read below.
packagePath?: string | string[]
// Mark dependencies external? Default: true.
deps?: boolean
// Mark devDependencies external? Default: false.
devDeps?: boolean
// Mark peerDependencies external? Default: true.
peerDeps?: boolean
// Mark optionalDependencies external? Default: true.
optDeps?: boolean
// Modules to force include in externals. Default: [].
include?: string | RegExp | (string | RegExp)[]
// Modules to force exclude from externals. Default: [].
exclude?: string | RegExp | (string | RegExp)[]
})
]
}
builtins?: boolean = true
Set the builtins option to false if you'd like to use some shims/polyfills for those. You'll most certainly need an other plugin as well.
builtinsPrefix?: boolean | 'add' | 'strip' | 'ignore' = 'add'
How to handle the node: scheme when importing builtins (i.e., import path from 'node:path').
- If
addortrue(the default, recommended), thenode:scheme is always added if missing, sopathbecomesnode:path. In effect, this dedupes your imports of Node builtins by homogenizing their names to their schemed version. - If
striporfalse, the scheme is always removed, sonode:pathbecomespath. In effect, this dedupes your imports of Node builtins by homogenizing their names to their scheme-less version. Schemed-only builtins likenode:testornode:sqliteare never stripped. ignorewill simply leave all builtins imports as written in your code. Caveat: if you writenode:pathbut one of your bundled dependencies usespath(or the other way around), your bundle will end up with bothnode:pathandpathimports.
[!NOTE] Scheme handling is always applied, regardless of the
builtinsoptions being enabled or not.
packagePath?: string | string[] = []
This option allows you to specify which package.json file(s) should be scanned for dependencies.
If not specified, the default is to start with the current directory's package.json then go up scan for all package.json files in parent directories recursively until either the root git directory is reached, the root of the monorepo is reached, or no other package.json can be found.
deps?: boolean = true<br>devDeps?: boolean = false<br>peerDeps?: boolean = true<br>optDeps?: boolean = true
Set the deps, devDeps, peerDeps and optDeps options to false to prevent the corresponding dependencies from being externalized, therefore letting Rollup/Vite bundle them with your code.…
Description from the npm listing.
- rollup
- vite
- plugin
- rollup-plugin
- vite-plugin
- external
- externals
- node
- builtin
- builtins
- dependencies
- devDependencies
- peerDependencies
- optionalDependencies
- modules
- monorepo
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Vite plugins plugins
All 20 rollup-plugin-node-externals alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/rollup-plugin-node-externals. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.