angular/angular-cli · warning
Invalid peer dependency ${peer} found in package.
Error message
Invalid peer dependency ${peer} found in package. What it means
While validating a package's peerDependencies during `ng add`, the CLI resolves each peer range with `npa.resolve`. If the peer name/range string is malformed, npm-package-arg throws and this warning is emitted; that peer is skipped. The add proceeds without that peer check.
Source
Thrown at packages/angular/cli/src/commands/add/cli.ts:854
);
}
}
}
return undefined;
}
private async getPeerDependencyConflicts(manifest: PackageManifest): Promise<string[] | false> {
if (!manifest.peerDependencies) {
return false;
}
const checks = Object.entries(manifest.peerDependencies).map(async ([peer, range]) => {
let peerIdentifier;
try {
peerIdentifier = npa.resolve(peer, range);
} catch {
this.context.logger.warn(`Invalid peer dependency ${peer} found in package.`);
return null;
}
if (peerIdentifier.type !== 'version' && peerIdentifier.type !== 'range') {
// type === 'tag' | 'file' | 'directory' | 'remote' | 'git'
// Cannot accurately compare these as the tag/location may have changed since install.
return null;
}
try {
const version = await this.findProjectVersion(peer);
if (!version) {
return null;
}
const options = { includePrerelease: true };
if (View on GitHub (pinned to bb72145f9a)
Solutions
- Open the offending package's package.json and fix the malformed peerDependencies entry.
- Pin to a version of the package that has valid peer metadata.
- If the package is yours, validate the range with `npm-package-arg` before publishing.
- Use `npm pkg get peerDependencies` to inspect quickly and correct the field.
Example fix
// before (invalid peer)
"peerDependencies": { "@angular/core": ">= >=16" }
// after
"peerDependencies": { "@angular/core": ">=16" } Defensive patterns
Strategy: validation
Validate before calling
try { npa.resolve(peer.name, peer.range); } catch { console.warn(`invalid peer: ${peer.name}`); } Type guard
function isValidPeerSpec(spec: unknown): spec is string { return typeof spec === 'string' && !!npa.tryResolve(spec); } Try / catch
try { peerIdentifier = npa.resolve(peer, range); } catch { logger.warn(`Invalid peer dependency ${peer}`); return null; } Prevention
- Validate peerDependencies with npm-package-arg before publishing packages.
- Prefer well-known semver ranges over exotic specs (git URLs, aliases) in peer deps.
- Audit third-party package manifests you publish internally.
- Pin to released versions of packages with valid metadata.
When it happens
Trigger: A dependency's package.json contains a peerDependencies entry with an invalid spec, e.g. a bad range like `">= <<"`, an empty range, or an unparseable name (git URL/alias syntax errors).
Common situations: Hand-edited or mis-published package.json; using an npm alias or prerelease tag syntax npm-package-arg cannot parse; typos in peer names in locally published/patched packages.
Related errors
- Could not parse package name from specifier: ${specifier}
- Invalid config found at ${workspace.filePath}. CLI should be
- Unable to fetch package information for '${context.packageId
- Invalid option key: '${key}'. Option keys must be alphanumer
- Incompatible peer dependencies found. See above for details.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/5f07a56576181c07.
Report an issue: GitHub.