Registry / devops / rollup-plugin-node

rollup-plugin-node

JSON →
library0.2.1jsnpmunverified

A Rollup plugin that improves Node.js usage in Rollup bundles by automatically declaring native Node.js modules as external and removing unknown require/import statements. Version 0.2.1 is the current stable release; the plugin has no recent updates. It helps resolve issues with optional imports from external libraries that Rollup handles poorly. Differentiators: lightweight, minimal configuration, and specifically targets Node.js native modules and optional dependencies.

npm install rollup-plugin-node
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-NODE
R
rollup-plugin-node
devopsjavascriptv0.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 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 rollupPluginNode from 'rollup-plugin-node'
const rollupPluginNode = require('rollup-plugin-node')
ESM-only; CommonJS require is not supported.
rollupPluginNode
import rollupPluginNode from 'rollup-plugin-node'
import { rollupPluginNode } from 'rollup-plugin-node'
Default export only; named export does not exist.
RollupPluginNodeOptions
import rollupPluginNode from 'rollup-plugin-node'; type Options = Parameters<typeof rollupPluginNode>[0]
import { RollupPluginNodeOptions } from 'rollup-plugin-node'
No type definitions exported; use TypeScript utility types.

Shows basic usage of rollup-plugin-node, including optional additionalOptionalDeps configuration.

import rollupPluginNode from 'rollup-plugin-node'; export default { input: 'src/index.js', output: { dir: 'output', format: 'cjs' }, plugins: [rollupPluginNode({ additionalOptionalDeps: { 'something.node': './addon' } })] };
Debug
Known issues
breakingRequires Rollup v1.20.0+ and Node v12.0.0+.
fix
Upgrade Rollup to v1.20.0+ and Node to v12.0.0+.
affects: <0.2.0
gotchaThis plugin removes unknown require/import statements, which may silently break code with legitimate but unrecognized dynamic imports.
fix
Manually declare any necessary external dependencies using Rollup's external option.
affects: >=0.0.0
gotchaPlace this plugin after @rollup/plugin-commonjs for correct processing.
fix
Reorder plugins: commonjs, then node.
affects: >=0.0.0
breakingThe plugin uses ESM; CommonJS require is not supported.
fix
Use import syntax or configure your project for ESM.
affects: >=0.2.0
Errors
Common errors & fixes
Error: Must use import to load ES Module: /path/to/rollup.config.js
Using require() to load a config file that uses ES module syntax.
fix
Rename file to .mjs or set "type": "module" in package.json.
TypeError: rollupPluginNode is not a function
Default import used incorrectly (e.g., via require or destructuring).
fix
Use `import rollupPluginNode from 'rollup-plugin-node'`.
[!] (rollup-plugin-node) Could not resolve 'fs'
Plugin failed to mark Node.js native module as external.
fix
Ensure rollup-plugin-node is included in plugins array and options are correct.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required to function as a plugin
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-node — npm install rollup-plugin-node · libregistry