externalSchematic doesn't work for globally installed nested dependencies #18098
Closed
1 of 15 tasks
Labels
area: @angular-devkit/schematics
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
type: bug/fix
Milestone
🐞 Bug report
Command (mark with an
x
)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),
fromng 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
The text was updated successfully, but these errors were encountered: