angular/angular-cli · error · Error

Package ${JSON.stringify(pkgName)} is not in package.json.

Error message

Package ${JSON.stringify(pkgName)} is not in package.json.

What it means

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.

Source

Thrown at packages/angular/cli/src/commands/update/update-resolver.ts:590

}

function _buildPackageList(
  options: UpdateResolverOptions,
  allDependencies: ReadonlyMap<string, VersionRange>,
  logger: logging.LoggerApi,
): Map<string, VersionRange> {
  const packages = new Map<string, VersionRange>();
  const inputPackages = options.packages ?? [];

  if (inputPackages.length === 0) {
    return packages;
  }

  for (const pkg of inputPackages) {
    const { name: pkgName, version: pkgVersion } = splitPackageName(pkg);

    if (!allDependencies.has(pkgName)) {
      throw new Error(`Package ${JSON.stringify(pkgName)} is not in package.json.`);
    }

    let targetVersion = pkgVersion;
    if (options.migrateOnly && !targetVersion && options.from) {
      targetVersion = options.from;
    }

    packages.set(pkgName, (targetVersion || (options.next ? 'next' : 'latest')) as VersionRange);
  }

  return packages;
}

async function resolvePackageVersion(
  registryClient: RegistryClient,
  metadata: PackageMetadata,
  range: string,
  next = false,

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Install the package first: npm install <pkg>.
  2. Verify spelling/scope of the package name against package.json.
  3. Use the package that actually declares it as a dependency and update that instead.
  4. Inspect allDependencies by searching your workspace package.json files for the name.

Example fix

// before
ng update rxjs  // rxjs not declared
// after
npm install rxjs
ng update rxjs
Defensive patterns

Strategy: validation

Validate before calling

const deps = { ...pkg.dependencies, ...pkg.devDependencies };
const requested = ['rxjs', 'lodash'];
const missing = requested.filter(p => !(p in deps));
if (missing.length) throw new Error(`Not in package.json: ${missing.join(', ')}`);

Type guard

function allDeclared(pkgJson, names) {
  const deps = { ...pkgJson.dependencies, ...pkgJson.devDependencies };
  return names.every(n => Object.hasOwn(deps, n));
}

Try / catch

try {
  await ngUpdate(packages);
} catch (e) {
  if (String(e.message).includes('is not in package.json')) {
    // filter the package list down to declared dependencies and retry
  }
}

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/76698690505ed573. Report an issue: GitHub.