Files
vercel__next.js/errors/import-esm-externals.mdx
Ayodele Samuel Adebayo 22fc63da72 docs: fix typos and links (#92541)
This PR cleans up small documentation and error-page issues: correct
TypeScript spelling where it was written as “Typescript”, use the proper
GitHub label in links, fix the MDN URL for `Map.prototype.values` in the
middleware upgrade guide.

No runtime or API behavior changes.
2026-05-13 10:25:23 +02:00

22 lines
766 B
Plaintext

---
title: ESM packages need to be imported
---
## Why This Error Occurred
Packages in node_modules that are published as ECMAScript Module, need to be `import`ed via `import ... from 'package'` or `import('package')`.
You get this error when using a different way to reference the package, e.g. `require()`.
## Possible Ways to Fix It
1. Use `import` or `import()` to reference the package instead. (Recommended)
2. If you are already using `import`, make sure that this is not changed by a transpiler, e. g. TypeScript or Babel.
3. Switch to loose mode (`experimental.esmExternals: 'loose'`), which tries to automatically correct this error.
## Useful Links
- [Node.js ESM require docs](https://nodejs.org/dist/latest-v16.x/docs/api/esm.html#esm_require)