diff --git a/packages/angular/cli/src/commands/add/cli.ts b/packages/angular/cli/src/commands/add/cli.ts index 5aaabbcd7ea4..5e55385d9984 100644 --- a/packages/angular/cli/src/commands/add/cli.ts +++ b/packages/angular/cli/src/commands/add/cli.ts @@ -346,7 +346,17 @@ export default class AddCommandModule } private async getCollectionName(): Promise { - const [, collectionName] = this.context.args.positional; + let [, collectionName] = this.context.args.positional; + + // The CLI argument may specify also a version, like `ng add @my/lib@13.0.0`, + // but here we need only the name of the package, like `@my/lib` + try { + const packageIdentifier = npa(collectionName); + collectionName = packageIdentifier.name ?? collectionName; + } catch (e) { + assertIsError(e); + this.context.logger.error(e.message); + } return collectionName; }