Skip to content

Bug: Could not find a declaration file for module 'utils' #7762

Closed as not planned
@LeeMoonki

Description

@LeeMoonki

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

utils

Playground Link

No response

Repro Code

import { ESLintUtils, TSESTree } from '@typescript-eslint/utils';

ESLint Config

No response

tsconfig

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "outDir": "lib",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "strictNullChecks": true,
    "skipLibCheck": true
  },
  "include": ["src", "index.ts"],
  "watchOptions": {
    "excludeDirectories": ["**/node_modules", "lib", "tests", "tests-etc"]
  }
}

Expected Result

I can use the module of @typescript-eslint/utils.

Actual Result

The following error occurs.

Cannot find module @typescript-eslint/utils or its corresponding type declarations

Additional Info

When I use @typescript-eslint/utils, the error

Cannot find module @typescript-eslint/utils or its corresponding type declarations

occurred.

The project structure is

.
├── packages/
│   └── eslint-plugin-foo/
│       ├── node_modules/
│       │   └── @typescript-eslint/
│       │       └── utils
│       ├── src/
│       │   └── rules/
│       │       └── some-rule.ts
│       └── tsconfig.json
└── tsconfig.json

When I use the package like,

import { ESLintUtils, TSESTree } from '@typescript-eslint/utils/dist';
...

the error disappear. But when I run a test for it, the following error shown

Package subpath './dist' is not defined by "exports" in somepath/packages/eslint-plugin-foo/node_modules/@typescript-eslint/utils/package.json

Versions

package version
@typescript-eslint/utils 6.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions