Skip to content

Commit 6d266c1

Browse files
committed
fix(@angular/cli): add fallbacks for migration package resolution
Before this commit, running `ng update @angular/cli` would fail when using the PNPM package manager. This update resolves the issue by implementing fallbacks in the migration package resolution logic, similar to the approach used in `NodeWorkflow`.
1 parent c545f77 commit 6d266c1

File tree

1 file changed

+3
-2
lines changed
  • packages/angular/cli/src/commands/update

1 file changed

+3
-2
lines changed

packages/angular/cli/src/commands/update/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ const UPDATE_SCHEMATIC_COLLECTION = path.join(__dirname, 'schematic/collection.j
8080
export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
8181
override scope = CommandScope.In;
8282
protected override shouldReportAnalytics = false;
83+
private readonly resolvePaths = [__dirname, this.context.root];
8384

8485
command = 'update [packages..]';
8586
describe = 'Updates your workspace and its dependencies. See https://update.angular.dev/.';
@@ -251,7 +252,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
251252
packageManagerForce: this.packageManagerForce(options.verbose),
252253
// __dirname -> favor @schematics/update from this package
253254
// Otherwise, use packages from the active workspace (migrations)
254-
resolvePaths: [__dirname, this.context.root],
255+
resolvePaths: this.resolvePaths,
255256
schemaValidation: true,
256257
engineHostCreator: (options) => new SchematicEngineHost(options.resolvePaths),
257258
});
@@ -555,7 +556,7 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
555556
// This avoids issues with package hoisting.
556557
try {
557558
const packageRequire = createRequire(packagePath + '/');
558-
migrations = packageRequire.resolve(migrations);
559+
migrations = packageRequire.resolve(migrations, { paths: this.resolvePaths });
559560
} catch (e) {
560561
assertIsError(e);
561562
if (e.code === 'MODULE_NOT_FOUND') {

0 commit comments

Comments
 (0)