- Error
- Reported by the binder
TS2664
Invalid module name in augmentation, module '{0}' cannot be found.
A declare module augmentation names a module that can't be resolved. Fix the module name or install the package being augmented.
What it means
A declare module "name" { ... } inside a module file augments an existing module, so the name has to resolve to one. Here it doesn't resolve to any file or package.
Example
declare module "missing-lib" {
export const extra: number;
}
export {};
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,16): error TS2664: Invalid module name in augmentation, module 'missing-lib' cannot be found.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Check the module name for typos; it must match what
importwould resolve. - Install the package (or its types) that you're augmenting.
- If you meant to declare a module that has no types, put
declare module "name"in a.d.tsfile that is not itself a module (no top-levelimport/export).