create-config icon indicating copy to clipboard operation
create-config copied to clipboard

Bug: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './config' is not defined by "exports"

Open flpmswap opened this issue 8 months ago • 1 comments

Environment

Node version: v20.19/v22.14 npm version: 10.8.2/10.9.2 Local ESLint version: v8.57.1 Global ESLint version: Not Found Operating System: linux 6.8.0-1021-azure and linux 5.15.167.4-microsoft-standard-WSL2

What parser are you using?

Other

What did you do?

Configuration
npm init
npm init @eslint/config@latest
# use `eslint-config-standard` shared config - npm 7+
npm init @eslint/config@latest -- --config eslint-config-standard
npx eslint ./index.js
# use `eslint-config-standard` shared config - npm 7+
npm init @eslint/config@latest -- --config eslint-config-standard

create an index.js in the root folder

export function test() {
    console.log('test')
}

also in the devDependencies in package.json, I´ve the followind dependencies

{
"devDependencies": {
    "@eslint/js": "^9.23.0",
    "eslint": "^8.57.1",
    "eslint-config-standard": "^17.1.0",
    "eslint-plugin-import": "^2.31.0",
    "eslint-plugin-n": "^16.6.2",
    "eslint-plugin-promise": "^6.6.0",
    "globals": "^16.0.0",
    "husky": "^9.1.7",
    "jest": "^29.7.0",
    "prettier": "^3.5.3"
  }
}

What did you expect to happen?

run eslint without errors for JS

What actually happened?

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './config' is not defined by "exports" in /workspaces/repro-eslint-codespace/node_modules/eslint/package.json imported from /workspaces/repro-eslint-codespace/eslint.config.js
    at exportsNotFound (node:internal/modules/esm/resolve:322:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:670:9)
    at packageResolve (node:internal/modules/esm/resolve:856:14)
    at moduleResolve (node:internal/modules/esm/resolve:946:18)
    at defaultResolve (node:internal/modules/esm/resolve:1188:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:130:49)

Link to Minimal Reproducible Example

https://github.com/flpmswap/repro-eslint-codespace

Participation

  • [ ] I am willing to submit a pull request for this issue.

Additional comments

No response

flpmswap avatar Mar 27 '25 20:03 flpmswap

@flpmswap Thanks for the report. I can confirm that this is a valid bug & I'm able to reproduce.

This issue seems to be introduced via https://github.com/eslint/create-config/pull/156

The issue is that defineConfig was exported recently in v9.22, but the project generated is using v8

I'll work on it, moving this to eslint/create-config.

snitin315 avatar Mar 28 '25 00:03 snitin315

Hi @snitin315 this continues to be an issue also for ESLINT + typescript .

Actually you should drop the TS support from this config generator because once selected the ESLint versions on the deps defaults to 8.x that is the only one that "name": "typescript-eslint", supports

See its package file here :

"dependencies": {
    "@typescript-eslint/eslint-plugin": "8.32.1",
    "@typescript-eslint/parser": "8.32.1",
    "@typescript-eslint/utils": "8.32.1" -> these dont support eslint 9.x 
  },
  "peerDependencies": {
    "eslint": "^8.57.0 || ^9.0.0", -> ok here 
    "typescript": ">=4.8.4 <5.9.0"
  },
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @typescript-eslint/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/eslint
npm WARN   dev eslint@"^9.26.0" from the root project
npm WARN   12 more (@babel/eslint-parser, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm WARN node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils
npm WARN   @typescript-eslint/utils@"5.62.0" from @typescript-eslint/[email protected]
npm WARN   node_modules/@typescript-eslint/type-utils
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/eslint
npm WARN   peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm WARN   node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils
npm WARN     @typescript-eslint/utils@"5.62.0" from @typescript-eslint/[email protected]
npm WARN     node_modules/@typescript-eslint/type-utils

jimmykane avatar May 13 '25 09:05 jimmykane