Typescript Esm Import Fix

Fix TypeScript ES module import errors by adding .js extensions to relative imports.

alexngai Updated

File contents

TypeScript ESM Import Fix

TypeScript with ES modules requires explicit .js extensions in relative imports — even though the source files are .ts.

  1. Add a .js extension to every relative import (./foo./foo.js).
  2. Keep it .js even when the file on disk is foo.ts.
  3. Run tsc --noEmit and confirm there are no module-resolution errors.

If you can't touch every import, set "moduleResolution": "bundler" in tsconfig.json.

alexngai/skill-tree/tree/main/docs/demo/skills/typescript-esm-import-fix commit c69cb2ef96

Frequently asked questions

npx skillmds@latest add alexngai/typescript-esm-import-fix