{"record":{"id":"d70b78e7445af4b2","repo":"angular/angular-cli","slug":"package-json-stringify-name-was-not-found-in-p","errorCode":null,"errorMessage":"Package ${JSON.stringify(name)} was not found in package.json.","messagePattern":"Package (.+?) was not found in package\\.json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/update/update-resolver.ts","lineNumber":435,"sourceCode":"  } catch {}\n\n  return null;\n}\n\nfunction getInstalledVersion(packageName: string, workspaceRoot: string): string | null {\n  const pkgJson = getInstalledPackageJson(packageName, workspaceRoot);\n\n  return pkgJson?.version ?? null;\n}\n\nfunction _buildLocalPackageInfo(\n  name: string,\n  allDependencies: ReadonlyMap<string, VersionRange>,\n  workspaceRoot: string,\n): PackageInfo {\n  const packageJsonRange = allDependencies.get(name);\n  if (!packageJsonRange) {\n    throw new Error(`Package ${JSON.stringify(name)} was not found in package.json.`);\n  }\n\n  const localPkgJson = getInstalledPackageJson(name, workspaceRoot);\n  if (!localPkgJson) {\n    throw new Error(`Package ${name} is not installed.`);\n  }\n\n  const installedVersion = localPkgJson.version;\n  const npmPackageJson: PackageMetadata = {\n    name,\n    versions: [installedVersion],\n    'dist-tags': {},\n  };\n\n  const logger = new logging.NullLogger();\n\n  return {\n    name,","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/update/update-resolver.ts#L417-L453","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nng update @angular-devkit/build-angular  # not in package.json, only transitive\n// error: Package \"@angular-devkit/build-angular\" was not found in package.json.\n// after\nng update @angular/cli  # the declared direct dependency","handlingStrategy":"validation","validationCode":"const pkgJson = require('./package.json');\nconst declared = { ...pkgJson.dependencies, ...pkgJson.devDependencies };\nif (!declared[name]) {\n  throw new Error(`${name} is not a direct dependency; update its parent instead`);\n}","typeGuard":"function isDirectDependency(name: string, pkgJson: { dependencies?: Record<string,string>; devDependencies?: Record<string,string> }): boolean {\n  return name in (pkgJson.dependencies ?? {}) || name in (pkgJson.devDependencies ?? {});\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["angular","cli","update","npm","package-json"],"backgroundTag":"package-not-in-package-json","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}