Home › JavaScript

TS2305: Module has no exported member (TypeScript) — how to fix

error TS2305: Module '"./utils"' has no exported member 'formatDate'.

Quick fix: Open the module (or its .d.ts) and check the exact exported names. Use import formatDate from './utils' if it is a default export, fix the spelling/casing, or install the library version that has that export (npm ls <pkg>). Restart the TS server after changing node_modules.

What it means

The module resolved fine (otherwise you would get TS2307), but the name in your import { ... } braces is not among its exports according to its type information. Note it is the types TypeScript checks: for a JavaScript library that is its .d.ts file or the @types/... package, not the runtime code.

Cause 1: typo or wrong casing

Export names are case-sensitive: formatDate and FormatDate are different. Check the source:

// utils.ts
export function formatDateTime(d: Date) { ... }
import { formatDateTime } from "./utils";

In VS Code, typing import { } from "./utils" and pressing Ctrl+Space inside the braces lists the real exports.

Cause 2: it is a default export

// utils.ts
export default function formatDate(d: Date) { ... }
import { formatDate } from "./utils";   // TS2305
import formatDate from "./utils";       // correct

The reverse also applies: export function x must be imported with braces.

Cause 3: the member was never exported

A function or type declared in a file is private to that module unless it has export:

interface User { id: string }        // not exported
export interface User { id: string } // exported

If you re-export through an index.ts barrel, make sure the barrel re-exports it too:

export * from "./user";
export { formatDate } from "./utils";

Cause 4: the library version changed its API

Libraries rename and remove exports between major versions. Check which version is installed and compare with the docs you are following:

npm ls some-lib

Either update your import to the new name or install the version the code was written for (npm install some-lib@<version>). Check the library's changelog or migration guide for the new name.

Cause 5: outdated or mismatched @types package

For libraries that ship without types, the names come from @types/<pkg>. If those types are older or newer than the library, exports can be missing. Install matching versions, or remove @types/<pkg> if the library now bundles its own types (look for a types field in its package.json).

Cause 6: stale editor state

After installing packages or switching branches the editor may show stale errors. Run npx tsc --noEmit to see what the compiler really reports, and in VS Code run TypeScript: Restart TS Server from the command palette.

Last updated 2026-12-02.