nrwl / nx

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

Targets in targetDefaults (nx.json) won't run #18934

Closed raketeFlo closed 1 year ago

raketeFlo commented 1 year ago

Current Behavior

I created a targetDefault for lint for all my modules in the nx.json to reduce repetitive configuration as mentioned in your recipes:

{
  "targetDefaults": {
    "lint": {
      "executor": "@nx/linter:eslint",
      "outputs": ["{options.outputFile}"],
      "options": {
        "lintFilePatterns": ["{projectRoot}/**/*.{ts,tsx,js,jsx}"],
        "quiet": true
      }
    }
  },
}

I removed the target in the project.json of the app-shell module. When I run nx run lint cart I receive the following error: Cannot find configuration for task cart:lint

Expected Behaviour

According to the docs it should run the targetDefault which is defined in the nx.json.

GitHub Repo

https://github.com/JoFlo07/nx-examples

Steps to Reproduce

  1. Run yarn install
  2. Run yarn run nx lint cart

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.17.0
   OS     : darwin-arm64
   yarn   : 1.22.19

   nx                 : 16.7.0-rc.1
   @nx/js             : 16.7.0-rc.1
   @nx/jest           : 16.7.0-rc.1
   @nx/linter         : 16.7.0-rc.1
   @nx/workspace      : 16.7.0-rc.1
   @nx/angular        : 16.7.0-rc.1
   @nx/cypress        : 16.7.0-rc.1
   @nx/devkit         : 16.7.0-rc.1
   @nx/eslint-plugin  : 16.7.0-rc.1
   @nx/react          : 16.7.0-rc.1
   @nrwl/tao          : 16.7.0-rc.1
   @nx/web            : 16.7.0-rc.1
   @nx/webpack        : 16.7.0-rc.1
   nx-cloud           : 16.3.0
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.0
   @ngrx/effects         : 16.0.0
   @ngrx/entity          : 16.0.0
   @ngrx/router-store    : 16.0.0
   @ngrx/store           : 16.0.0
   @ngrx/store-devtools  : 16.0.0

✨  Done in 0.52s.

Failure Logs

Error: Cannot find configuration for task cart:lint
    at ProcessTasks.createTask (/Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/create-task-graph.js:156:19)
    at ProcessTasks.processTasks (/Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/create-task-graph.js:23:39)
    at createTaskGraph (/Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/create-task-graph.js:192:21)
    at createTaskGraphAndValidateCycles (/Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/run-command.js:68:63)
    at /Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/run-command.js:93:31
    at Generator.next (<anonymous>)
    at /Users/florian/work-flow/nx-examples/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/florian/work-flow/nx-examples/node_modules/tslib/tslib.js:114:16)
    at /Users/florian/work-flow/nx-examples/node_modules/nx/src/tasks-runner/run-command.js:90:114
error Command failed with exit code 1.

Package Manager Version

yarn v1.22.19

Operating System

Additional Information

No response

FrozenPandaz commented 1 year ago

You must include at least a "lint": {} in your project.json to signify that the project should have a lint target.

Example: https://github.com/nrwl/nx/blob/master/packages/nx/project.json#L101

Does that make sense?

raketeFlo commented 1 year ago

Thank you @FrozenPandaz. That worked. I will correct it in your recipes page then and submit a PR, because it is shown without any target in the project.json which is not working.

github-actions[bot] commented 11 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.