{"id":22757,"library":"vite-plugin-node-externals","title":"vite-plugin-node-externals","description":"Vite plugin that wraps rollup-plugin-node-externals to automatically externalize Node.js built-in modules and npm dependencies in Vite builds. Version 0.0.1, released in 2021. No active release cadence. The main differentiator is that it fixes Vite's plugin ordering issue by enforcing 'pre' type, allowing rollup-plugin-node-externals to work correctly. However, the author recommends against using it and suggests directly configuring rollup-plugin-node-externals with enforce: 'pre' instead.","status":"deprecated","version":"0.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-node-externals","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-node-externals","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-node-externals","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core logic for externalizing Node.js modules and dependencies","package":"rollup-plugin-node-externals","optional":false}],"imports":[{"note":"ESM-only; package has no CJS export.","wrong":"const nodeExternals = require('vite-plugin-node-externals')","symbol":"default","correct":"import nodeExternals from 'vite-plugin-node-externals'"},{"note":"Named export also available, but default export is the plugin function.","wrong":"import nodeExternals from 'vite-plugin-node-externals'","symbol":"nodeExternals","correct":"import { nodeExternals } from 'vite-plugin-node-externals'"},{"note":"TypeScript type import only.","wrong":"import { PluginOptions } from 'vite-plugin-node-externals'","symbol":"PluginOptions","correct":"import type { PluginOptions } from 'vite-plugin-node-externals'"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport nodeExternals from 'vite-plugin-node-externals';\n\nexport default defineConfig({\n  plugins: [\n    nodeExternals(),\n  ],\n});","lang":"javascript","description":"Basic setup to externalize Node builtins and deps in a Vite library build."},"warnings":[{"fix":"Replace with rollup-plugin-node-externals and set enforce: 'pre'.","message":"Author recommends not using this package; use rollup-plugin-node-externals directly with enforce: 'pre'.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use import syntax or switch to a CJS-compatible wrapper.","message":"Does not support CommonJS require() – only ES module imports work.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Use rollup-plugin-node-externals directly for full option support.","message":"Options passed to nodeExternals() may not be fully forwarded to rollup-plugin-node-externals due to thin wrapper.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change require() to import() or switch to dynamic import.","cause":"Package is ESM-only, but project uses CommonJS require()","error":"Error: Must use import to load ES Module: /path/to/vite-plugin-node-externals/index.mjs"},{"fix":"Use import nodeExternals from 'vite-plugin-node-externals' (default) or import { nodeExternals } from '...' (named).","cause":"Importing named export 'nodeExternals' from default export","error":"TypeError: nodeExternals is not a function"},{"fix":"Use rollup-plugin-node-externals directly or update vite-plugin-node-externals if available.","cause":"Vite version mismatch; package may not support Vite 3+","error":"Error: The plugin 'vite-plugin-node-externals' is not compatible with current Vite version"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}