diff --git a/packages/angular/cli/src/commands/add/cli.ts b/packages/angular/cli/src/commands/add/cli.ts index 1fd2c58f975c..55768138e4f2 100644 --- a/packages/angular/cli/src/commands/add/cli.ts +++ b/packages/angular/cli/src/commands/add/cli.ts @@ -10,7 +10,7 @@ import { analytics, tags } from '@angular-devkit/core'; import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools'; import npa from 'npm-package-arg'; import { dirname, join } from 'path'; -import { compare, intersects, prerelease, satisfies, valid } from 'semver'; +import { Range, compare, intersects, prerelease, satisfies, valid } from 'semver'; import { Argv } from 'yargs'; import { PackageManager } from '../../../lib/config/workspace-schema'; import { isPackageNameSafeForAnalytics } from '../../analytics/analytics'; @@ -47,10 +47,10 @@ interface AddCommandArgs extends SchematicsCommandArgs { * when attempting to find a compatible version for a package. * The key is a package name and the value is a SemVer range of versions to exclude. */ -const packageVersionExclusions: Record = { - // @angular/localize@9.x versions do not have peer dependencies setup - '@angular/localize': '9.x', - // @angular/material@7.x versions have unbounded peer dependency ranges (>=7.0.0) +const packageVersionExclusions: Record = { + // @angular/localize@9.x and earlier versions as well as @angular/localize@10.0 prereleases do not have peer dependencies setup. + '@angular/localize': '<10.0.0', + // @angular/material@7.x versions have unbounded peer dependency ranges (>=7.0.0). '@angular/material': '7.x', }; @@ -189,7 +189,10 @@ export class AddCommandModule return false; } // Excluded package versions should not be considered - if (versionExclusions && satisfies(value.version, versionExclusions)) { + if ( + versionExclusions && + satisfies(value.version, versionExclusions, { includePrerelease: true }) + ) { return false; }