Skip to content
Latchkey

tsc TS2459: Module 'x' declares 'y' locally, but it is not exported in CI

TS2459 means the name you imported does exist in the target module, but it is private (declared without export). tsc distinguishes this from a missing name to point you at the fix: export it.

What this error means

tsc fails with "error TS2459: Module './utils' declares 'helper' locally, but it is not exported." at the import line.

tsc
src/main.ts:1:10 - error TS2459: Module '"./utils"' declares 'helper' locally, but it is not exported.

1 import { helper } from './utils';
           ~~~~~~

Common causes

The name is declared without export

The target module defines helper but never exports it, so it is module-private and cannot be imported.

An export statement was dropped in a refactor

The export keyword was removed or the symbol was left out of an index re-export, while a consumer still imports it.

How to fix it

Export the symbol from its module

  1. Open the module named in the error.
  2. Add export to the declaration, or re-export it from the index.
  3. Re-run tsc to confirm the import resolves.
src/utils.ts
// utils.ts
export function helper() { /* ... */ }

Import a name that is actually exported

If the symbol is intentionally private, import the public API the module does export instead.

How to prevent it

  • Keep index re-exports in sync with what consumers import.
  • Export symbols that are part of a module public API.
  • Run tsc across the project so dropped exports surface immediately.

Frequently asked questions

What causes "TS2459 "declares ... locally, but it is not exported""?
The target module defines helper but never exports it, so it is module-private and cannot be imported.
How do I fix TS2459 "declares ... locally, but it is not exported"?
Export the symbol from its module

Related guides

References

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