angular/angular-cli · error · Error

Package ${name} is not installed.

Error message

Package ${name} is not installed.

What it means

After confirming the package is declared in package.json, _buildLocalPackageInfo loads the installed package's package.json via getInstalledPackageJson(name, workspaceRoot). If the package is not physically installed in node_modules (or cannot be resolved from the workspace root), it throws 'Package <name> is not installed.'

Source

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

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,
    npmPackageJson,
    installed: {
      version: installedVersion as VersionRange,
      packageJson: localPkgJson,
      updateMetadata: _getUpdateMetadata(localPkgJson, logger),

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Run `npm install` (or yarn/pnpm install) to restore node_modules, then retry ng update.
  2. Verify installation with `npm ls <name>`; reinstall specifically with `npm install <name>`.
  3. Clear caches and reinstall if node_modules is corrupted (`rm -rf node_modules && npm ci`).

Example fix

// before (fresh clone)
ng update @angular/core
// error: Package @angular/core is not installed.
// after
npm install
ng update @angular/core
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
import { resolve } from 'path';
const installed = existsSync(resolve(workspaceRoot, 'node_modules', name, 'package.json'));
if (!installed) {
  throw new Error(`${name} missing from node_modules — run npm install first`);
}

Prevention

When it happens

Trigger: Running `ng update <name>` when the package is in package.json but absent from node_modules — after a fresh clone without npm install, a failed/partial install, or the package being pruned.

Common situations: Fresh checkout running ng update before installing dependencies; deleted/corrupted node_modules; yarn/pnpm workspaces where hoisting hides the package; CI caches missing the package.

Related errors


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