← All notes

moduleResolution tells TypeScript how the host resolves module specifiers

Answer: Module resolution is the process of finding the file a module specifier refers to. The host — a runtime such as Node.js, or a bundler — defines the algorithm, and moduleResolution tells the compiler which algorithm to imitate.

Why the compiler has to be told

The ECMAScript specification says how import and export bind, but it leaves file lookup to the host. Runtimes and bundlers therefore differ, especially when they support both ESM and CommonJS. There is no single right answer, so the compiler learns the rules from configuration options.

module describes the expected module format. moduleResolution describes how specifiers map to files. TypeScript does not rewrite import specifiers on emit, because that mapping is host-defined.

The moduleResolution options

classic is the oldest mode and should not be used for new work. node10 (formerly node) models older CommonJS lookup, including node_modules and omitted .js extensions, and is a poor model of modern Node.js ESM rules.

node16 and nodenext follow modern Node.js, where ESM specifiers may not omit extensions or /index.js suffixes, while require still may. For those values, module and moduleResolution must match. bundler is for bundlers: it supports package.json imports and exports, but it does not require file extensions on relative import paths.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Microsoft (TypeScript Handbook), TypeScript Modules: Theory, CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); Microsoft (TSConfig reference), TSConfig: moduleResolution, CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft (TypeScript Handbook), TypeScript Modules: Theory, CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); Microsoft (TSConfig reference), TSConfig: moduleResolution, CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE).

Cite this

Permanent ID: iil:note:n3z75vq2

iinventedlight. 2026. "moduleResolution tells TypeScript how the host resolves module specifiers." iinventedlight Library, iil:note:n3z75vq2, version of 2026-11-17. https://iinventedlight.com/library/notes/typescript-module-resolution/. License: CC-BY-4.0.

@misc{iil_note_n3z75vq2,
  author = {{iinventedlight}},
  title = {{moduleResolution tells TypeScript how the host resolves module specifiers}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-17},
  url = {https://iinventedlight.com/library/notes/typescript-module-resolution/},
  note = {Permanent ID iil:note:n3z75vq2. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/typescript-module-resolution.md.