{"id":22019,"library":"rollup-plugin-external-node-modules","title":"rollup-plugin-external-node-modules","description":"Rollup plugin that automatically marks all node_modules packages as external, preventing them from being bundled. Version 1.0.1 is current, stable, and likely low-maintenance. It simplifies Rollup configuration by removing the need to manually list externals. Ships TypeScript types. Key differentiator: zero-config approach compared to manual externals or other plugins like @rollup/plugin-node-resolve combined with externals.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/d8corp/rollup-plugin-external-node-modules","tags":["javascript","rollup-plugin","env","front-end","typescript"],"install":[{"cmd":"npm install rollup-plugin-external-node-modules","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-external-node-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-external-node-modules","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin compatibility","package":"rollup","optional":true}],"imports":[{"note":"Plugin exports a default function via ESM; CommonJS require may not work if package is ESM-only (check package.json: type: module).","wrong":"const external = require('rollup-plugin-external-node-modules')","symbol":"default","correct":"import external from 'rollup-plugin-external-node-modules'"},{"note":"The default export is the plugin itself; you can rename it during import. This is not a named export.","wrong":null,"symbol":"externalNodeModules","correct":"import externalNodeModules from 'rollup-plugin-external-node-modules'"},{"note":"The package ships TypeScript types; type-only imports should use 'import type'. Named export 'RollupPluginExternalNodeModules' does not exist as a value.","wrong":"import { RollupPluginExternalNodeModules } from 'rollup-plugin-external-node-modules'","symbol":"types","correct":"import type { RollupPluginExternalNodeModules } from 'rollup-plugin-external-node-modules'"}],"quickstart":{"code":"import external from 'rollup-plugin-external-node-modules';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm',\n  },\n  plugins: [external()],\n});","lang":"typescript","description":"Basic Rollup configuration using the plugin to automatically externalize all node_modules packages."},"warnings":[{"fix":"Do not manually add packages to Rollup's 'external' option when using this plugin, or ensure plugin is listed first.","message":"Plugin does not respect Rollup's 'external' option if both are used; run order matters.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Manually add any specific subpaths to Rollup's 'external' option if needed.","message":"Only marks packages under node_modules as external; does not handle deep imports like 'lodash/fp' correctly in all cases.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use with @yarnpkg/plugin-pnp and ensure node_modules is present or handle manually.","message":"Plugin does not work with PnP (Plug'n'Play) environments by default; may not detect dependencies correctly.","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add Rollup's builtins plugin or manually externalize built-ins: external: ['fs', 'path', ...].","cause":"Plugin externalizes everything in node_modules but not Node.js built-ins if they are not listed as dependencies.","error":"The following Node.js built-in modules were not found: fs, path"},{"fix":"Ensure the package is installed or add it to Rollup's 'external' option.","cause":"If 'some-package' is not in node_modules (e.g., a monorepo workspace), the plugin will not externalize it.","error":"Error: Could not resolve 'some-package'"},{"fix":"Use import external from 'rollup-plugin-external-node-modules' (default import).","cause":"Incorrect import; likely used named import instead of default import.","error":"TypeError: external is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}