Registry / devops / rollup-plugin-node-globals

rollup-plugin-node-globals

JSON →
library1.4.0jsnpmunverified

A Rollup plugin (v1.4.0, last released in 2018) that injects Node.js global polyfills—process, global, Buffer, __dirname, __filename—into bundled code, mimicking browserify's global shimming. It optimizes process.nextTick and process.browser to only pull in required parts, and resolves __dirname/__filename to the file on disk. Useful for migrating CommonJS or Node-centric code to ES module bundles, but superseded by @rollup/plugin-inject or manual polyfills; unmaintained and incompatible with Rollup v2+.

npm install rollup-plugin-node-globals
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-NODE
R
rollup-plugin-node-globals
devopsjavascriptv1.4.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

default
✓ import globals from 'rollup-plugin-node-globals'
✗ const globals = require('rollup-plugin-node-globals')
ESM default export; CJS require() breaks in some bundler contexts.
plugin
✓ import globals from 'rollup-plugin-node-globals'; export default { plugins: [globals()] }
✗ export default { plugins: [require('rollup-plugin-node-globals')()] }
Require() in a Rollup config may cause issues if the config is ESM.
options
✓ globals({ process: false, global: false, buffer: false, dirname: false, filename: false, baseDir: '/some/path' })
✗ globals({ process: true })
Setting options to true is counterproductive; use false to disable, not enable. baseDir must be an absolute path.

Basic Rollup configuration using rollup-plugin-node-globals to polyfill process, global, Buffer, __dirname, and __filename.

import globals from 'rollup-plugin-node-globals'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'iife' }, plugins: [ globals({ process: true, global: true, buffer: true, dirname: true, filename: true, baseDir: process.cwd() }) ] };
Debug
Known issues
deprecatedPackage is unmaintained and deprecated. Use @rollup/plugin-inject or manual polyfills instead.
fix
Replace with @rollup/plugin-inject and configure polyfills manually.
affects: >=1.0.0
gotchaThe plugin may not work with Rollup v2 or higher due to plugin API changes.
fix
Use @rollup/plugin-inject or fork/update the plugin.
affects: 1.4.0
gotcha__dirname and __filename are resolved to absolute paths on disk, not relative to the output bundle.
fix
Manually replace with dynamic paths if needed.
affects: >=1.0.0
gotchaThe plugin does not polyfill all Node.js globals (e.g., setImmediate, clearImmediate) unless they are used in a global context.
fix
Add individual polyfills for missing globals.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-node-globals'
Package not installed or not in node_modules.
fix
Run npm install rollup-plugin-node-globals --save-dev.
Error: 'plugin' is not defined
Invalid import syntax (e.g., using require in an ESM config).
fix
Use import globals from 'rollup-plugin-node-globals' in an ESM context.
Error: Unexpected token: name (globals)
Rollup plugin configuration object missing parentheses when calling globals as a function.
fix
Call globals() instead of just globals in the plugins array.
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies
rollup-pluginutilsrequiredUsed for creating filter and transforming modules
acornoptionalFor parsing JavaScript and detecting identifier usage
Agent activity
2 hits · last 30 days
node
2
Resources
rollup-plugin-node-globals — npm install rollup-plugin-node-globals · libregistry