nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.8k stars 2.38k forks source link

Cannot find configuration for task {projectName}:lint after migrating to 20.0.10 #28826

Open riceboyler opened 3 weeks ago

riceboyler commented 3 weeks ago

Current Behavior

I'm getting an error when attempting to run nx lint on any of the apps/libs in my repo after migrating to v20.0.10. This is hosting two Next.js apps and nx run {projectName} works fine, but linting does not. Note, this repo is using inferred tasks.

Expected Behavior

Linting should just work like it did in v19.

GitHub Repo

No response

Steps to Reproduce

  1. Have an existing nx monorepo at a version less than 20.0.10
  2. Run nx migrate latest and watch it download and install 20.0.10
  3. Run pnpm i --no-lockfile as instructed
  4. Run nx migrate --run-migrations --if-exists
  5. Attempt to run nx lint {projectName} --fix

Nx Report

╰─ nx report

NX Report complete - copy this into the issue template

Node : 20.17.0 OS : darwin-arm64 Native Target : aarch64-macos pnpm : 9.12.1

nx : 20.0.10 @nx/js : 20.0.10 @nx/jest : 20.0.10 @nx/eslint : 20.0.10 @nx/workspace : 20.0.10 @nx/cypress : 20.0.10 @nx/devkit : 20.0.10 @nx/eslint-plugin : 20.0.10 @nx/next : 20.0.10 @nx/playwright : 20.0.10 @nx/react : 20.0.10 @nx/vite : 20.0.10 @nx/web : 20.0.10 @nx/webpack : 20.0.10 typescript : 5.5.4

Registered Plugins: @nx/next/plugin @nx/cypress/plugin @nx/jest/plugin @nx/eslint/plugin @nx/playwright/plugin

Failure Logs

nx lint webviews --fix --verbose

NX Cannot find configuration for task webviews:lint

Error: Cannot find configuration for task webviews:lint at ProcessTasks.createTask (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/create-task-graph.js:157:19) at ProcessTasks.processTasks (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13__@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/create-task-graph.js:34:39) at createTaskGraph (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/create-task-graph.js:242:21) at createTaskGraphAndRunValidations (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/run-command.js:78:63) at ensureWorkspaceIsInSyncAndGetGraphs (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13__@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/run-command.js:132:21) at runCommandForTasks (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/run-command.js:114:47) at /Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/run-command.js:105:35 at handleErrors (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13__@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/utils/handle-errors.js:9:30) at runCommand (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/tasks-runner/run-command.js:104:59) at Object.runOne (/Users/riceboyler/source/@chtbks/nx-paid-webviews/nodemodules/.pnpm/nx@20.0.10@swc-node+register@1.10.9@swc+core@1.9.1@swc+helpers@0.5.13__@swc+types@0.1.14_t_yc76nam4t7wmmxixmaewf25aca/node_modules/nx/src/command-line/run/run-one.js:48:59)

Package Manager Version

pnpm v9.12

Operating System

Additional Information

As part of this migration I did also update to the new eslint.config.mjs format for my former .eslintrc.json files. Not sure if that's related or not. I did manually update the nx.json file to point to the new eslint file. Also, when running nx show project {projectName} --web Lint is not shown as an available task.

Is there a way to regenerate inferred tasks? (I already tried running nx add @nx/eslint to no avail.)

riceboyler commented 2 weeks ago

I'm noticing that in a fresh install of NX20, the eslint config file is a .js not .mjs that the ESLint Configuration Migration tool uses by default. Not sure if that's related or not.

RobbyRabbitman commented 2 weeks ago

The nx eslint plugin does not infer a lint target for mjs eslint config files. Either use a cjs file or specify type module in your package.json if your project uses esm.