{"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,"search_vec":"'2018':13 'browserifi':28 'buffer':21 'bundl':25,63 'centric':58 'code':26,59 'commonj':54 'dirnam':22 'dirname/__filename':45 'disk':50 'es':61 'file':48 'filenam':23 'global':5,17,20,30 'incompat':73 'inject':15 'javascript':77 'last':10 'manual':69 'migrat':53 'mimick':27 'modul':62 'node':4,57 'node-centr':56 'node.js':16 'optim':33 'part':42 'plugin':3,8,80 'polyfil':18,70 'process':19 'process.browser':36 'process.nexttick':34 'pull':39 'releas':11 'requir':41 'resolv':44 'rollup':2,7,75,79 'rollup-plugin':78 'rollup-plugin-node-glob':1 'rollup/plugin-inject':67 'shim':31 'supersed':65 'unmaintain':71 'use':51 'v1.4.0':9 'v2':76","created_at":"2026-04-27T17:03:38.075735+00:00","updated_at":"2026-04-27T17:03:38.075735+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/calvinmetcalf/rollup-plugin-node-globals","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-node-globals","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}