angular/angular-cli · error · Error
Package ${JSON.stringify(name)} was not found in package.jso
Error message
Package ${JSON.stringify(name)} was not found in package.json. What it means
_buildLocalPackageInfo requires the package being updated to appear in the workspace's dependency ranges (dependencies/devDependencies read from package.json). _buildLocalPackageInfo throws when allDependencies.get(name) returns nothing, i.e. the package name isn't declared in package.json, so no version range can be resolved for the update plan.
Source
Thrown at packages/angular/cli/src/commands/update/update-resolver.ts:435
} catch {}
return null;
}
function getInstalledVersion(packageName: string, workspaceRoot: string): string | null {
const pkgJson = getInstalledPackageJson(packageName, workspaceRoot);
return pkgJson?.version ?? null;
}
function _buildLocalPackageInfo(
name: string,
allDependencies: ReadonlyMap<string, VersionRange>,
workspaceRoot: string,
): PackageInfo {
const packageJsonRange = allDependencies.get(name);
if (!packageJsonRange) {
throw new Error(`Package ${JSON.stringify(name)} was not found in package.json.`);
}
const localPkgJson = getInstalledPackageJson(name, workspaceRoot);
if (!localPkgJson) {
throw new Error(`Package ${name} is not installed.`);
}
const installedVersion = localPkgJson.version;
const npmPackageJson: PackageMetadata = {
name,
versions: [installedVersion],
'dist-tags': {},
};
const logger = new logging.NullLogger();
return {
name,View on GitHub (pinned to bb72145f9a)
Solutions
- Verify the name is listed in package.json dependencies/devDependencies (`npm ls <name>`).
- Fix typos in the package name passed to ng update.
- If updating a transitive package, update its direct parent instead: `ng update <parent>` or `npm update <name>`.
- Install the package first (`npm install <name>`) if you actually depend on it, then update.
Example fix
// before ng update @angular-devkit/build-angular # not in package.json, only transitive // error: Package "@angular-devkit/build-angular" was not found in package.json. // after ng update @angular/cli # the declared direct dependency
Defensive patterns
Strategy: validation
Validate before calling
const pkgJson = require('./package.json');
const declared = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
if (!declared[name]) {
throw new Error(`${name} is not a direct dependency; update its parent instead`);
} Type guard
function isDirectDependency(name: string, pkgJson: { dependencies?: Record<string,string>; devDependencies?: Record<string,string> }): boolean {
return name in (pkgJson.dependencies ?? {}) || name in (pkgJson.devDependencies ?? {});
} Prevention
- Only pass direct dependencies to ng update; check package.json first.
- Use `npm ls <name>` to confirm the package is declared at the workspace root.
- Fix name typos by copying from package.json.
When it happens
Trigger: Running `ng update <name>` for a package not listed in package.json (e.g. a transitive dependency, a typo, or a package only present in another sub-project), while it is installed in node_modules.
Common situations: Updating transitive dependencies directly; typos in package names; workspaces/monorepos where the package is a dependency of a nested package.json, not the root; leftovers removed from package.json but still in node_modules.
Related errors
- Unable to install packages
- Incompatible peer dependencies found. See above for details.
- Package ${name} is not installed.
- Repository is not clean. Please commit or stash any changes
- A single package must be specified when using the 'migrate-o
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/d70b78e7445af4b2.
Report an issue: GitHub.