{"record":{"id":"89487b95484824bd","repo":"angular/angular-cli","slug":"node-packages-may-not-be-installed-try-installing","errorCode":null,"errorMessage":"Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.","messagePattern":"Node packages may not be installed\\. Try installing with '(.+?) install'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/command-builder/architect-base-command-module.ts","lineNumber":220,"sourceCode":"      true,\n    );\n  }\n\n  private warnOnMissingNodeModules(): void {\n    const basePath = this.context.workspace?.basePath;\n    if (!basePath) {\n      return;\n    }\n\n    const workspaceResolve = createRequire(basePath + '/').resolve;\n\n    try {\n      workspaceResolve('@angular/core');\n\n      return;\n    } catch {}\n\n    this.context.logger.warn(\n      `Node packages may not be installed. Try installing with '${this.context.packageManager.name} install'.`,\n    );\n  }\n\n  protected getArchitectTarget(): string {\n    return this.commandName;\n  }\n\n  protected async onMissingTarget(defaultMessage: string): Promise<1> {\n    const { logger } = this.context;\n    const choices = this.missingTargetChoices;\n\n    if (!choices?.length) {\n      logger.error(defaultMessage);\n\n      return 1;\n    }\n","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/command-builder/architect-base-command-module.ts#L202-L238","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the workspace package manager install: `npm install` (or yarn/pnpm/bun install as configured).","If already installed, delete node_modules and the lockfile, then reinstall.","Ensure you run `ng` from the workspace root where node_modules exists.","Verify @angular/core is present in node_modules and listed in package.json dependencies."],"exampleFix":"// before\n$ ng build   # Error/warning about missing packages\n// after\n$ npm install\n$ ng build","handlingStrategy":"validation","validationCode":"let resolved; try { resolved = require.resolve('@angular/core', { paths: [process.cwd()] }); } catch { console.error('Run your package manager install first.'); process.exit(1); }","typeGuard":"function nodeModulesReady(cwd: string): boolean { try { require.resolve('@angular/core', { paths: [cwd] }); return true; } catch { return false; } }","tryCatchPattern":"try { workspaceResolve('@angular/core'); } catch { logger.warn(`Node packages may not be installed. Try installing with '${pmName} install'.`); }","preventionTips":["Always run the package manager install after cloning.","Don't switch package managers without removing node_modules and lockfiles.","Verify CI cache includes a complete node_modules.","Run ng commands from the workspace root."],"tags":["node-modules","install","architect","environment"],"backgroundTag":"missing-node-modules","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}