Skip to content

[bug] Eslint server failed to start due to Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in \node_modules\eslint-plugin-react-dom\package.json #1288

@demosofa

Description

@demosofa

Describe the bug

After installing this package and updating all related ESLint packages to the latest version, I noticed that ESLint wasn't working. I then opened the ESLint Output panel in VSCode, and it showed the following:

[Info - 1:22:19 PM] ESLint server is starting.
[Info - 1:22:21 PM] ESLint server running in node v22.19.0
[Info - 1:22:22 PM] ESLint server is running.
[Info - 1:22:45 PM] ESLint library loaded from: F:\my-nextjs-project\node_modules\eslint\lib\api.js
[Error - 1:23:09 PM] Calculating config file for file:///f%3A/my-nextjs-project/frontend/contexts/AblyContext.tsx) failed.
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in F:\my-nextjs-project\node_modules\eslint-plugin-react-dom\package.json
at exportsNotFound (node:internal/modules/esm/resolve:317:10)
at packageExportsResolve (node:internal/modules/esm/resolve:607:13)
at resolveExports (node:internal/modules/cjs/loader:657:36)
at Module._findPath (node:internal/modules/cjs/loader:724:31)
at Module._resolveFilename (node:internal/modules/cjs/loader:1376:27)
at defaultResolveImpl (node:internal/modules/cjs/loader:1032:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1037:22)
at Module._load (node:internal/modules/cjs/loader:1199:37)
at c._load (node:electron/js2c/node_init:2:17993)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)

Reproduction

  1. eslint.config.mjs:
import eslintReact from '@eslint-react/eslint-plugin';
import { fixupConfigRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslintJS from '@eslint/js';
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
import importPlugin from 'eslint-plugin-import';
import noAutoFix from 'eslint-plugin-no-autofix';
import unusedImports from 'eslint-plugin-unused-imports';
import { defineConfig } from 'eslint/config';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tsEslint from 'typescript-eslint';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
	baseDirectory: __dirname,
	recommendedConfig: eslintJS.configs.recommended,
	allConfig: eslintJS.configs.all
});

export default defineConfig(
	{
		ignores: ['**/next/', '**/dist/', '**/node_modules/']
	},
	fixupConfigRules(compat.extends('next/core-web-vitals', 'prettier')),
	tsEslint.configs.strictTypeChecked,
	tsEslint.configs.stylisticTypeChecked,
	{
		extends: [
			importPlugin.flatConfigs.recommended,
			importPlugin.flatConfigs.typescript,
			eslintReact.configs['recommended-typescript']
		],
		plugins: {
			'no-autofix': noAutoFix,
			'unused-imports': unusedImports
		},

		languageOptions: {
			parser: tsEslint.parser,
			parserOptions: {
				projectService: true,
				tsconfigRootDir: import.meta.dirname
			}
		},

		settings: {
			'import-x/resolver-next': [
				createTypeScriptImportResolver({
					alwaysTryTypes: true // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
				})
			]
		},

		rules: {
			'prefer-template': 'error',
			'prefer-const': [
				'error',
				{
					destructuring: 'all',
					ignoreReadBeforeAssign: false
				}
			],
			'no-duplicate-imports': 'error',
			'no-duplicate-case': 'error',
			'import/named': 'error',
			'import/default': 'error',
			'import/namespace': 'error',
			'import/no-unresolved': 'error',
			'import/no-duplicates': 'error',
			'@typescript-eslint/no-empty-object-type': 'warn',
			'@typescript-eslint/consistent-type-definitions': 'warn',
			'@typescript-eslint/array-type': 'warn',
			'@typescript-eslint/prefer-nullish-coalescing': [
				'error',
				{
					ignorePrimitives: true
				}
			],
			'@typescript-eslint/prefer-reduce-type-parameter': 'warn',
			'@typescript-eslint/no-dynamic-delete': 'warn',
			'@typescript-eslint/no-unsafe-return': 'warn',
			'@typescript-eslint/no-unsafe-argument': 'warn',
			'@typescript-eslint/no-confusing-void-expression': [
				'warn',
				{
					ignoreArrowShorthand: true
				}
			],
			'@typescript-eslint/no-extraneous-class': 'off',
			'@typescript-eslint/no-base-to-string': 'off',
			'@typescript-eslint/prefer-promise-reject-errors': 'off',
			'@typescript-eslint/consistent-type-definitions': 'off',
			'no-autofix/@typescript-eslint/consistent-type-definitions': 'warn',
			'@typescript-eslint/restrict-template-expressions': [
				'error',
				{
					allowNumber: true
				}
			],
			'@typescript-eslint/no-misused-promises': [
				'error',
				{
					checksVoidReturn: false
				}
			],
			'@typescript-eslint/restrict-plus-operands': [
				'error',
				{
					skipCompoundAssignments: true
				}
			],
			'@typescript-eslint/unbound-method': 'warn',
			'@typescript-eslint/no-unsafe-assignment': 'warn',
			'@typescript-eslint/no-var-requires': 'off',
			'@typescript-eslint/no-unused-vars': 'off',
			'@typescript-eslint/no-explicit-any': 'warn',
			'@typescript-eslint/triple-slash-reference': 'warn',
			'no-unused-vars': 'off',
			'unused-imports/no-unused-imports': 'error',
			'unused-imports/no-unused-vars': [
				'warn',
				{
					caughtErrorsIgnorePattern: '^_',
					vars: 'all',
					varsIgnorePattern: '^_',
					args: 'after-used',
					argsIgnorePattern: '^_'
				}
			]
		}
	},
	{
		files: ['**/*.js', '**/*.jsx'],
		rules: {
			'@typescript-eslint/no-unsafe-member-access': 'off',
			'@typescript-eslint/no-unsafe-call': 'off',
			'@typescript-eslint/no-unnecessary-condition': 'off',
			'@typescript-eslint/dot-notation': 'off'
		}
	}
);
  1. package.json (Note: I used ncu -i command, so the version numbers shown here were all the latest versions)
{
	"sideEffects": false,
	"type": "module",
	"dependencies": {
		"@next/bundle-analyzer": "15.5.6",
		"@sentry/nextjs": "^10.20.0",
		"next": "15.5.6",
		"next-compose-plugins": "^2.2.1",
		"next-pwa": "^5.6.0",
		"react": "^19.2.0",
		"react-dom": "^19.2.0",
	},
	"devDependencies": {
		"@eslint-react/eslint-plugin": "^2.2.2",
		"@eslint/compat": "^1.4.0",
		"@eslint/eslintrc": "^3.3.1",
		"@eslint/js": "^9.38.0",
		"@trivago/prettier-plugin-sort-imports": "^5.2.2",
		"@types/react": "19.2.2",
		"@types/react-dom": "^19.2.2",
		"eslint": "^9.38.0",
		"eslint-config-next": "15.5.6",
		"eslint-config-prettier": "^10.1.8",
		"eslint-import-resolver-typescript": "^4.4.4",
		"eslint-plugin-import": "npm:eslint-plugin-import-x@^4.16.1",
		"eslint-plugin-no-autofix": "^2.1.0",
		"eslint-plugin-unused-imports": "^4.2.0",
		"prettier": "^3.6.2",
		"prettier-plugin-jsdoc": "^1.3.3",
		"prettier-plugin-tailwindcss": "^0.7.1",
		"typescript": "^5.9.3",
		"typescript-eslint": "^8.46.1"
	}
}
  1. tsconfig.json
{
	"compilerOptions": {
		/* Type Checking */
		"alwaysStrict": true,
		"exactOptionalPropertyTypes": false,
		"strict": true,
		"noImplicitAny": true,
		"noImplicitOverride": true,
		"noImplicitThis": true,
		"noImplicitReturns": false,
		"noUnusedLocals": false,
		"useUnknownInCatchVariables": true,
		/* Emit */
		"sourceMap": false,
		"noEmit": true,
		"removeComments": true,
		/* JavaScript Support */
		"allowJs": true,
		/* Interop Constraints */
		"esModuleInterop": true,
		"allowSyntheticDefaultImports": true,
		"forceConsistentCasingInFileNames": true,
		"isolatedModules": true,
		/* Language and Environment */
		"jsx": "preserve",
		"lib": ["dom", "dom.iterable", "esnext", "webworker"],
		"target": "ESNext",
		/* Projects */
		"incremental": true,
		/* Completeness */
		"skipLibCheck": true,
		/* Modules */
		"module": "ESNext",
		"moduleResolution": "Node",
		"resolveJsonModule": true,
		"types": ["node"],
		"baseUrl": "./",
		"paths": {
			"@/*": ["*"]
		}
	},
	"include": [
		"next-env.d.ts",
		"next.config.js",
		"eslint.config.mjs",
		"**/*.ts",
		"**/*.tsx",
		"**/*.js",
		"**/*.jsx"
	],
	"exclude": ["node_modules"]
}

Expected behavior

Eslint server should not be failed when including rules from this package

Platform and versions

node -v
v20.19.2

Stack trace

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in F:\my-nextjs-project\node_modules\eslint-plugin-react-dom\package.json
    at exportsNotFound (node:internal/modules/esm/resolve:317:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:607:13)
    at resolveExports (node:internal/modules/cjs/loader:657:36)
    at Module._findPath (node:internal/modules/cjs/loader:724:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1376:27)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1032:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1037:22)
    at Module._load (node:internal/modules/cjs/loader:1199:37)
    at c._load (node:electron/js2c/node_init:2:17993)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions