Skip to content

[CLI][Schematics] Override Angular Schematics issue - Collection "[Schematics folder path]" cannot be resolved. - Windows #29978

Closed

Description

@SlawomiKussowski

Command

generate

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Unknown

Description

This is similar issue to #29559.
The behavior has been fixed but only in ng generate command is executed in the root folder.

If you try to override standard Angular Schematics with a custom one by the use of schematicCollections option in angular.json file like for instance:

 "cli": { "analytics": false, 
"schematicCollections": [
   "./schematics", 
  "@schematics/angular" ]
 }

And create your custom schematics (index.ts):

import {
  externalSchematic,
  Rule,
  SchematicContext,
  Tree
} from '@angular-devkit/schematics';
import { Schema as ComponentOptions } from '@schematics/angular/component/schema';

export function generateComponent(options: ComponentOptions): Rule {
  console.log('options', structuredClone(options));
  return (_tree: Tree, _context: SchematicContext) => {
    return externalSchematic(
      "@schematics/angular",
      "component",
      options
    );
  };
}

And then go to any subfolder.
It will end up with an error message like this one:
Collection "D:\projects\schematics-test_v19\src\app\schematics" cannot be resolved.

Please use the attached repo to reproduce the issue:

schematics-test_v19.zip

Minimal Reproduction

Run npm install and then go to a subfolder, for instance:
cd .\src\app
and try to generate a component using:
ng g c
command.

Exception or Error

Collection "D:\\projects\\schematics-test_v19\\src\\app\\schematics" cannot be resolved.

Your Environment

Angular CLI: 19.2.5
Node: 22.13.0
Package Manager: npm 8.6.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.5
@angular-devkit/build-angular   19.2.5
@angular-devkit/core            19.2.5
@angular-devkit/schematics      19.2.5
@angular/cli                    19.2.5
@schematics/angular             19.2.5
rxjs                            7.8.1
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

This is similar issue to #29559.

Activity

  1. self-assigned this
    on Apr 1, 2025
  2. added
    freq1: low
    on Apr 1, 2025
  3. added theissue type on Apr 1, 2025
  4. added 3 commits that reference this issue on Apr 1, 2025
    6d7ef34
    a09f37d
    c109bd2
  5. added 2 commits that reference this issue on Apr 1, 2025
    4955ee0
    e5aec56
  6. angular-automatic-lock-bot commented on May 2, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: @angular-devkit/schematicsfreq1: lowseverity3: brokentype: bug/fix

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions