Skip to content

Automatically adding ESLint fails with: "An unhandled exception occurred: Project target does not exist." #22706

@FieteO

Description

@FieteO

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

I don't know

Description

Automatically adding ESLint via the cli fails with An unhandled exception occurred: Project target does not exist.
This issue occurred while following the Angular Creating Libraries tutorial.

🔬 Minimal Reproduction

Generate the project (as described in the Creating Libraries guide)

dev@ubu ~/Documents/exploration/angular-libaries $ ng new new-workspace --no-create-application
CREATE new-workspace/README.md (1058 bytes)
...
...
CREATE new-workspace/.vscode/tasks.json (938 bytes)
✔ Packages installed successfully.
    Successfully initialized git.

dev@ubu ~/Documents/exploration/angular-libaries $ cd new-workspace/
dev@ubu ~/Documents/exploration/angular-libaries/new-workspace (master)$ ng generate library my-lib
CREATE projects/my-lib/.browserslistrc (600 bytes)
...
...
UPDATE tsconfig.json (963 bytes)
✔ Packages installed successfully.

dev@ubu ~/Documents/exploration/angular-libaries/new-workspace (master)$ ng build my-lib --configuration development
Building Angular Package

------------------------------------------------------------------------------
Building entry point 'my-lib'
------------------------------------------------------------------------------
✔ Compiling with Angular sources in Ivy full compilation mode.
✔ Generating FESM2020
✔ Generating FESM2015
✔ Copying assets
✔ Writing package manifest
✔ Built my-lib

------------------------------------------------------------------------------
Built Angular Package
 - from: /home/dev/Documents/exploration/angular-libaries/new-workspace/projects/my-lib
 - to:   /home/dev/Documents/exploration/angular-libaries/new-workspace/dist/my-lib
------------------------------------------------------------------------------

Build at: 2022-02-14T10:16:20.529Z - Time: 10904ms

Run ng lint

dev@ubu ~/Documents/exploration/angular-libaries/new-workspace (master)$ ng lint my-lib

Cannot find "lint" target for the specified project.

You should add a package that implements linting capabilities.

For example:
  ng add @angular-eslint/schematics

Would you like to add ESLint now? Yes
ℹ Using package manager: npm
✔ Found compatible package version: @angular-eslint/schematics@13.1.0.
✔ Package information loaded.

The package @angular-eslint/schematics@13.1.0 will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
    
    All @angular-eslint dependencies have been successfully installed 🎉
    
    Please see https://github.com/angular-eslint/angular-eslint for how to add ESLint configuration to your project.
    
    
    We detected that you have a single project in your workspace and no existing linter wired up, so we are configuring ESLint for you automatically.
    
    Please see https://github.com/angular-eslint/angular-eslint for more information.
    
CREATE projects/my-lib/.eslintrc.json (842 bytes)
UPDATE package.json (1481 bytes)
UPDATE angular.json (1457 bytes)
✔ Packages installed successfully.
An unhandled exception occurred: Project target does not exist.
See "/tmp/ng-RgRZtd/angular-errors.log" for further details.

🔥 Exception or Error

Exception of the ng lint my-lib command

An unhandled exception occurred: Project target does not exist.
See "/tmp/ng-RgRZtd/angular-errors.log" for further details.

Contents of angular-errors.log

[error] Error: Project target does not exist.
    at findProjectTarget (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:49:15)
    at Object.getBuilderName (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:62:46)
    at WorkspaceNodeModulesArchitectHost.getBuilderNameForTarget (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:101:35)
    at LintCommand.runSingleTarget (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/models/architect-command.js:242:55)
    at LintCommand.runArchitectTarget (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/models/architect-command.js:295:35)
    at LintCommand.run (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/models/architect-command.js:236:27)
    at LintCommand.validateAndRun (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/models/command.js:136:33)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async runCommand (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/models/command-runner.js:224:24)
    at async default_1 (/home/dev/Documents/exploration/angular-libaries/new-workspace/node_modules/@angular/cli/lib/cli/index.js:70:31)

Running ng lint my-lib again

dev@ubu ~/Documents/exploration/angular-libaries/new-workspace (master)$ ng lint my-lib

Linting "my-lib"...
An unhandled exception occurred: Failed to load config "../../.eslintrc.json" to extend from.
Referenced from: /home/dev/Documents/exploration/angular-libaries/new-workspace/projects/my-lib/.eslintrc.json
See "/tmp/ng-sZU4Sc/angular-errors.log" for further details.

🌍 Your Environment




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 13.2.3
Node: 14.15.4
Package Manager: npm 8.4.0
OS: linux x64

Angular: 13.2.2
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.3
@angular-devkit/build-angular   13.2.3
@angular-devkit/core            13.2.3
@angular-devkit/schematics      13.2.3
@angular/cli                    13.2.3
@schematics/angular             13.2.3
ng-packagr                      13.2.1
rxjs                            7.5.4
typescript                      4.5.5

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions