Skip to content

Commit 944caf2

Browse files
committed
refactor(@angular/cli): use ignorePeerDependencies in update command
This commit updates the `ng update` command to utilize the `ignorePeerDependencies` option when installing packages. Previously, the command forced the installation (`--force`) when NPM 7+ was detected to workaround peer dependency issues. Now, it uses the more specific `ignorePeerDependencies` option (mapping to `--legacy-peer-deps` for NPM), which is safer and cleaner.
1 parent 71d4e8a commit 944caf2

File tree

1 file changed

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

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
521521

522522
if (success) {
523523
const { root: commandRoot } = this.context;
524-
const force = await shouldForcePackageManager(packageManager, logger, options.verbose);
524+
const ignorePeerDependencies = await shouldForcePackageManager(
525+
packageManager,
526+
logger,
527+
options.verbose,
528+
);
525529
const tasks = new Listr([
526530
{
527531
title: 'Cleaning node modules directory',
@@ -545,15 +549,14 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
545549
async task() {
546550
try {
547551
await packageManager.install({
548-
force,
552+
ignorePeerDependencies,
549553
});
550554
} catch (e) {
551555
throw new CommandError('Unable to install packages');
552556
}
553557
},
554558
},
555559
]);
556-
557560
try {
558561
await tasks.run();
559562
} catch (e) {

0 commit comments

Comments
 (0)