{"record":{"id":"76698690505ed573","repo":"angular/angular-cli","slug":"package-json-stringify-pkgname-is-not-in-packa","errorCode":null,"errorMessage":"Package ${JSON.stringify(pkgName)} is not in package.json.","messagePattern":"Package (.+?) is not in package\\.json\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/update/update-resolver.ts","lineNumber":590,"sourceCode":"}\n\nfunction _buildPackageList(\n  options: UpdateResolverOptions,\n  allDependencies: ReadonlyMap<string, VersionRange>,\n  logger: logging.LoggerApi,\n): Map<string, VersionRange> {\n  const packages = new Map<string, VersionRange>();\n  const inputPackages = options.packages ?? [];\n\n  if (inputPackages.length === 0) {\n    return packages;\n  }\n\n  for (const pkg of inputPackages) {\n    const { name: pkgName, version: pkgVersion } = splitPackageName(pkg);\n\n    if (!allDependencies.has(pkgName)) {\n      throw new Error(`Package ${JSON.stringify(pkgName)} is not in package.json.`);\n    }\n\n    let targetVersion = pkgVersion;\n    if (options.migrateOnly && !targetVersion && options.from) {\n      targetVersion = options.from;\n    }\n\n    packages.set(pkgName, (targetVersion || (options.next ? 'next' : 'latest')) as VersionRange);\n  }\n\n  return packages;\n}\n\nasync function resolvePackageVersion(\n  registryClient: RegistryClient,\n  metadata: PackageMetadata,\n  range: string,\n  next = false,","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/update/update-resolver.ts#L572-L608","documentation":"Thrown by _buildPackageList when a package passed on the `ng update` command line is not present in the workspace's aggregated dependency map. Unlike error 50 (which happens during per-package info building), this fails early while building the list of packages to update.","triggerScenarios":"`ng update <pkg>` where <pkg> is absent from all dependency sections of every package.json in the workspace; passing a package name that only exists as a transitive dependency; misspelled or wrongly-scoped name.","commonSituations":"CLI typo; trying to update a library that is not a direct dependency; forgetting that ng update only operates on declared dependencies; monorepo where the dependency is in a nested project's package.json that isn't part of the resolution set.","solutions":["Install the package first: npm install <pkg>.","Verify spelling/scope of the package name against package.json.","Use the package that actually declares it as a dependency and update that instead.","Inspect allDependencies by searching your workspace package.json files for the name."],"exampleFix":"// before\nng update rxjs  // rxjs not declared\n// after\nnpm install rxjs\nng update rxjs","handlingStrategy":"validation","validationCode":"const deps = { ...pkg.dependencies, ...pkg.devDependencies };\nconst requested = ['rxjs', 'lodash'];\nconst missing = requested.filter(p => !(p in deps));\nif (missing.length) throw new Error(`Not in package.json: ${missing.join(', ')}`);","typeGuard":"function allDeclared(pkgJson, names) {\n  const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };\n  return names.every(n => Object.hasOwn(deps, n));\n}","tryCatchPattern":"try {\n  await ngUpdate(packages);\n} catch (e) {\n  if (String(e.message).includes('is not in package.json')) {\n    // filter the package list down to declared dependencies and retry\n  }\n}","preventionTips":["Build ng update package lists programmatically from package.json contents.","Avoid passing transitive dependencies to ng update.","Double-check scope and spelling of CLI arguments.","Grep all workspace package.json files before updating in monorepos."],"tags":["angular-cli","package-json","cli-arguments","update"],"backgroundTag":"package-not-in-package-json","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}