Skip to content

v6: Cannot find module '@typescript-eslint/*' or its corresponding type declarations #7284

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Overview

A handful of folks have mentioned that after upgrading to v6, trying to import from @typescript-eslint/* packages such as @typescript-eslint/utils causes a new TypeScript type error:

import { ESLintUtils } from '@typescript-eslint/utils';
Cannot find module '@typescript-eslint/utils' or its corresponding type declarations.

This is not a bug. We intentionally dropped support in v6 for Node <16 as those versions of node are EOL. v6 uses package.json exports - which requires Node 16+ and isn't supported by that older module resolution strategy.

To fix the issue, switch your TSConfig's module resolution to a newer version, most likely "bundler", "node16", or "nodenext". See the aka.ms/tsconfig "moduleResolution" docs for more information.

{
    "compilerOptions": {
        "moduleResolution": "bundler"
    }
}

See TypeScript's new modules reference docs for more information.

Issues that are duplicates of this one:

https://arethetypeswrong.github.io/?p=%40typescript-eslint%2Futils%406.0.0 also shows a nice table of which moduleResolution values we support. It's all of them except node10.

Keeping this issue open so it shows up more in searches.

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix: user errorissue was fixed by correcting the configuration / correcting the codeworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions