Skip to content
Latchkey

Rollup "Missing global variable name" - Fix UMD Externals in CI

For UMD/IIFE output, every external dependency must map to a browser global. When you mark a module external but do not tell Rollup its global name, it warns "Missing global variable name" and guesses - producing a bundle that references the wrong global at runtime.

What this error means

A UMD/IIFE Rollup build prints (!) Missing global variable name for each external (e.g. react), with "Use "output.globals" to specify ... Guessing 'React'". The bundle builds but may break in the browser.

rollup
(!) Missing global variable names
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to external modules:
react (guessing "React")
react-dom (guessing "ReactDOM")

Common causes

Externals without output.globals

A UMD/IIFE build externalizes dependencies (so they are not bundled) but does not declare the global each maps to, so Rollup cannot reference them correctly.

Wrong global name guessed

Rollup's guess (capitalized package name) is often wrong (e.g. react-dom is ReactDOM, not ReactDom), so the runtime global lookup fails.

How to fix it

Declare output.globals for every external

Map each external to its real browser global name.

rollup.config.js
// rollup.config.js
export default {
  external: ['react', 'react-dom'],
  output: {
    format: 'umd',
    name: 'MyLib',
    globals: { react: 'React', 'react-dom': 'ReactDOM' },
  },
}

Use an output format that does not need globals

  1. If you do not need UMD/IIFE, build es/cjs where externals do not require globals.
  2. For libraries, ship es + cjs and let consumers bundle, avoiding UMD globals entirely.
  3. Provide output.name for the UMD bundle itself when you do keep UMD.

How to prevent it

  • Always pair UMD/IIFE externals with output.globals.
  • Verify global names against each library's real UMD global.
  • Prefer es/cjs outputs unless a UMD global is genuinely required.

Frequently asked questions

What causes ""Missing global variable name""?
A UMD/IIFE build externalizes dependencies (so they are not bundled) but does not declare the global each maps to, so Rollup cannot reference them correctly.
How do I fix "Missing global variable name"?
Map each external to its real browser global name.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card