{"id":22147,"library":"rollup-plugin-node-globals","title":"rollup-plugin-node-globals","description":"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+.","status":"deprecated","version":"1.4.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/calvinmetcalf/rollup-plugin-node-globals","tags":["javascript","rollup-plugin"],"install":[{"cmd":"npm install rollup-plugin-node-globals","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-node-globals","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-node-globals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for creating filter and transforming modules","package":"rollup-pluginutils","optional":false},{"reason":"For parsing JavaScript and detecting identifier usage","package":"acorn","optional":true}],"imports":[{"note":"ESM default export; CJS require() breaks in some bundler contexts.","wrong":"const globals = require('rollup-plugin-node-globals')","symbol":"default","correct":"import globals from 'rollup-plugin-node-globals'"},{"note":"Require() in a Rollup config may cause issues if the config is ESM.","wrong":"export default { plugins: [require('rollup-plugin-node-globals')()] }","symbol":"plugin","correct":"import globals from 'rollup-plugin-node-globals'; export default { plugins: [globals()] }"},{"note":"Setting options to true is counterproductive; use false to disable, not enable. baseDir must be an absolute path.","wrong":"globals({ process: true })","symbol":"options","correct":"globals({ process: false, global: false, buffer: false, dirname: false, filename: false, baseDir: '/some/path' })"}],"quickstart":{"code":"import globals from 'rollup-plugin-node-globals';\n\nexport default {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'iife' },\n  plugins: [\n    globals({\n      process: true,\n      global: true,\n      buffer: true,\n      dirname: true,\n      filename: true,\n      baseDir: process.cwd()\n    })\n  ]\n};","lang":"javascript","description":"Basic Rollup configuration using rollup-plugin-node-globals to polyfill process, global, Buffer, __dirname, and __filename."},"warnings":[{"fix":"Replace with @rollup/plugin-inject and configure polyfills manually.","message":"Package is unmaintained and deprecated. Use @rollup/plugin-inject or manual polyfills instead.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use @rollup/plugin-inject or fork/update the plugin.","message":"The plugin may not work with Rollup v2 or higher due to plugin API changes.","severity":"gotcha","affected_versions":"1.4.0"},{"fix":"Manually replace with dynamic paths if needed.","message":"__dirname and __filename are resolved to absolute paths on disk, not relative to the output bundle.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add individual polyfills for missing globals.","message":"The plugin does not polyfill all Node.js globals (e.g., setImmediate, clearImmediate) unless they are used in a global context.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install rollup-plugin-node-globals --save-dev.","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'rollup-plugin-node-globals'"},{"fix":"Use import globals from 'rollup-plugin-node-globals' in an ESM context.","cause":"Invalid import syntax (e.g., using require in an ESM config).","error":"Error: 'plugin' is not defined"},{"fix":"Call globals() instead of just globals in the plugins array.","cause":"Rollup plugin configuration object missing parentheses when calling globals as a function.","error":"Error: Unexpected token: name (globals)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}