Skip to content

externalSchematic doesn't work for globally installed nested dependencies #18098

@bmayen

Description

@bmayen

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, this previously worked in v8

Description

Using "externalSchematic" on a collection defined in a dependency of a custom schematic, does not work when the custom schematic is installed globally. Globally installed npm packages are not flattened/deduped and the nested collection dependency is not found by "externalSchematic".

🔬 Minimal Reproduction

Running ng new -c schematic-1.

"schematic-1" is installed globally (npm i schematic-1 -g) and has an npm dependency on "schematic-2".

Under the global node_modules folder, "schematic-1" has a nested node_modules folder containing "schematic-2". If installed locally, npm will flatten the dependencies and "schematic-1" and "schematic-2" will be siblings, but a global install will nest "schematic-2" under "schematic-1".

"schematic-1" calls externalSchematic('schematic-2', 'ng-add', options), from ng new.

When installed globally, this fails with "Collection schematic-2 cannot be resolved" When installed locally, and dependencies are flatted, this succeeds.

🔥 Exception or Error

Collection schematic-2 cannot be resolved

🌍 Your Environment

Angular CLI: 9.1.9
Node: 10.21.0
OS: darwin x64

Angular:
...
Ivy Workspace:

Package Version

@angular-devkit/architect 0.901.9
@angular-devkit/core 9.1.9
@angular-devkit/schematics 9.1.9
@schematics/angular 9.1.9
@schematics/update 0.901.9
rxjs 6.5.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions