{"id":22148,"library":"rollup-plugin-node","title":"rollup-plugin-node","description":"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.","status":"active","version":"0.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/aurelhann/rollup-plugin-node","tags":["javascript","rollup","nodejs"],"install":[{"cmd":"npm install rollup-plugin-node","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-node","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-node","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to function as a plugin","package":"rollup","optional":false}],"imports":[{"note":"ESM-only; CommonJS require is not supported.","wrong":"const rollupPluginNode = require('rollup-plugin-node')","symbol":"default","correct":"import rollupPluginNode from 'rollup-plugin-node'"},{"note":"Default export only; named export does not exist.","wrong":"import { rollupPluginNode } from 'rollup-plugin-node'","symbol":"rollupPluginNode","correct":"import rollupPluginNode from 'rollup-plugin-node'"},{"note":"No type definitions exported; use TypeScript utility types.","wrong":"import { RollupPluginNodeOptions } from 'rollup-plugin-node'","symbol":"RollupPluginNodeOptions","correct":"import rollupPluginNode from 'rollup-plugin-node'; type Options = Parameters<typeof rollupPluginNode>[0]"}],"quickstart":{"code":"import rollupPluginNode from 'rollup-plugin-node';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs'\n  },\n  plugins: [rollupPluginNode({\n    additionalOptionalDeps: {\n      'something.node': './addon'\n    }\n  })]\n};","lang":"javascript","description":"Shows basic usage of rollup-plugin-node, including optional additionalOptionalDeps configuration."},"warnings":[{"fix":"Upgrade Rollup to v1.20.0+ and Node to v12.0.0+.","message":"Requires Rollup v1.20.0+ and Node v12.0.0+.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Manually declare any necessary external dependencies using Rollup's external option.","message":"This plugin removes unknown require/import statements, which may silently break code with legitimate but unrecognized dynamic imports.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Reorder plugins: commonjs, then node.","message":"Place this plugin after @rollup/plugin-commonjs for correct processing.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use import syntax or configure your project for ESM.","message":"The plugin uses ESM; CommonJS require is not supported.","severity":"breaking","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Rename file to .mjs or set \"type\": \"module\" in package.json.","cause":"Using require() to load a config file that uses ES module syntax.","error":"Error: Must use import to load ES Module: /path/to/rollup.config.js"},{"fix":"Use `import rollupPluginNode from 'rollup-plugin-node'`.","cause":"Default import used incorrectly (e.g., via require or destructuring).","error":"TypeError: rollupPluginNode is not a function"},{"fix":"Ensure rollup-plugin-node is included in plugins array and options are correct.","cause":"Plugin failed to mark Node.js native module as external.","error":"[!] (rollup-plugin-node) Could not resolve 'fs'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}