{"record":{"id":"8ea2bf7698685980","repo":"angular/angular-cli","slug":"could-not-resolve-angular-core-package-json-fro","errorCode":null,"errorMessage":"Could not resolve '@angular/core/package.json' from '${workspacePath}'. Is Angular installed in this project? Falling back to the bundled guide.","messagePattern":"Could not resolve '@angular/core/package\\.json' from '(.+?)'\\. Is Angular installed in this project\\? Falling back to the bundled guide\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/mcp/tools/best-practices.ts","lineNumber":126,"sourceCode":"\n      return undefined;\n    }\n\n    if (!isAllowed) {\n      throw new Error(\n        `Workspace path is outside the allowed MCP roots: ${workspacePath}. ` +\n          \"You can use 'list_projects' to find available workspaces.\",\n      );\n    }\n  }\n\n  // 1. Resolve the path to package.json\n  let pkgJsonPath: string;\n  try {\n    const workspaceRequire = createRequire(workspacePath);\n    pkgJsonPath = workspaceRequire.resolve('@angular/core/package.json');\n  } catch (e) {\n    logger.warn(\n      `Could not resolve '@angular/core/package.json' from '${workspacePath}'. ` +\n        'Is Angular installed in this project? Falling back to the bundled guide.',\n    );\n\n    return undefined;\n  }\n\n  // 2. Read and parse package.json, then find and read the guide.\n  try {\n    const pkgJsonContent = await readFile(pkgJsonPath, 'utf-8');\n    const pkgJson = JSON.parse(pkgJsonContent);\n    const bestPracticesInfo = pkgJson['angular']?.bestPractices;\n\n    if (\n      bestPracticesInfo &&\n      bestPracticesInfo.format === 'markdown' &&\n      typeof bestPracticesInfo.path === 'string'\n    ) {","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/mcp/tools/best-practices.ts#L108-L144","documentation":"To load version-specific best practices, the tool resolves `@angular/core/package.json` from the workspace using createRequire. If the resolution fails, Angular is not installed (or not resolvable) in that workspace, so the tool warns and falls back to the bundled guide.","triggerScenarios":"createRequire(workspacePath).resolve('@angular/core/package.json') throws because node_modules lacks @angular/core or module resolution fails from that path.","commonSituations":"Running the MCP tool in a non-Angular directory; dependencies not installed (`npm install` not run); pnpm/yarn PnP layouts where resolution via Node require fails; monorepo subfolders without local node_modules.","solutions":["Run `npm install` (or your package manager's install) in the workspace so @angular/core exists.","Point the tool at the actual Angular workspace root, not an unrelated directory.","If using pnpm/Yarn PnP, ensure the setup allows standard Node require resolution, or rely on the bundled guide fallback."],"exampleFix":"// before: empty workspace\nmy-app/ (no node_modules)\n// after\nnpm install\n# @angular/core/package.json resolvable, version-specific guide loads","handlingStrategy":"validation","validationCode":"import { createRequire } from 'node:module';\nimport { existsSync } from 'node:fs';\nif (!existsSync('node_modules/@angular/core/package.json')) {\n  console.warn('@angular/core not installed; run `npm install` first.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const pkgJsonPath = createRequire(workspacePath).resolve('@angular/core/package.json');\n} catch {\n  return bundledGuide(); // graceful fallback\n}","preventionTips":["Always run package installation in the workspace before MCP doc tools.","Point tools at the Angular workspace root, not arbitrary subfolders.","For pnpm/PnP setups, verify Node require resolution works for @angular/core."],"tags":["mcp","module-resolution","angular","best-practices"],"backgroundTag":"module-not-found","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}