angular/angular-cli · warning

Node packages may not be installed. Try installing with '${t

Error message

Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.

What it means

Before executing an architect target, the CLI checks that node_modules is usable by resolving @angular/core. When resolution fails, it warns that Node packages may not be installed and suggests running the workspace package manager's install command.

Source

Thrown at packages/angular/cli/src/command-builder/architect-base-command-module.ts:220

      true,
    );
  }

  private warnOnMissingNodeModules(): void {
    const basePath = this.context.workspace?.basePath;
    if (!basePath) {
      return;
    }

    const workspaceResolve = createRequire(basePath + '/').resolve;

    try {
      workspaceResolve('@angular/core');

      return;
    } catch {}

    this.context.logger.warn(
      `Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.`,
    );
  }

  protected getArchitectTarget(): string {
    return this.commandName;
  }

  protected async onMissingTarget(defaultMessage: string): Promise<1> {
    const { logger } = this.context;
    const choices = this.missingTargetChoices;

    if (!choices?.length) {
      logger.error(defaultMessage);

      return 1;
    }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Run the workspace package manager install: `npm install` (or yarn/pnpm/bun install as configured).
  2. If already installed, delete node_modules and the lockfile, then reinstall.
  3. Ensure you run `ng` from the workspace root where node_modules exists.
  4. Verify @angular/core is present in node_modules and listed in package.json dependencies.

Example fix

// before
$ ng build   # Error/warning about missing packages
// after
$ npm install
$ ng build
Defensive patterns

Strategy: validation

Validate before calling

let resolved; try { resolved = require.resolve('@angular/core', { paths: [process.cwd()] }); } catch { console.error('Run your package manager install first.'); process.exit(1); }

Type guard

function nodeModulesReady(cwd: string): boolean { try { require.resolve('@angular/core', { paths: [cwd] }); return true; } catch { return false; } }

Try / catch

try { workspaceResolve('@angular/core'); } catch { logger.warn(`Node packages may not be installed. Try installing with '${pmName} install'.`); }

Prevention

When it happens

Trigger: Running any `ng` architect command (build/serve/test) in a workspace where node_modules is missing or incomplete — fresh clone without install, pruned node_modules, or corrupted install where @angular/core cannot be resolved.

Common situations: Fresh `git clone` without `npm install`; CI caching restored a partial node_modules; switching package managers (npm→pnpm) leaving a broken layout; deleting node_modules manually.

Related errors


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