{"record":{"id":"7d344dd0d0bfbfa1","repo":"angular/angular-cli","slug":"could-not-find-a-package-json-are-you-in-a-node-p","errorCode":null,"errorMessage":"Could not find a package.json. Are you in a Node project?","messagePattern":"Could not find a package\\.json\\. Are you in a Node project\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/update/update-resolver.ts","lineNumber":872,"sourceCode":"        `Please perform the following steps to update:\\n` +\n        `  1. Manually update the versions for these packages in your catalog configuration file ` +\n        `(e.g., pnpm-workspace.yaml or .yarnrc.yml).\\n` +\n        `  2. Run '${installCmd}' to install the updated versions.\\n` +\n        `  3. Run the following command(s) from the workspace root to execute the migration schematics:\\n` +\n        `${migrationCommands}`,\n    );\n  }\n}\n\nexport async function resolveUserUpdatePlan(\n  options: UpdateResolverOptions,\n  packageManager: PackageManager,\n  logger: logging.LoggerApi,\n): Promise<UpdatePlan> {\n  const workspaceRoot = options.workspaceRoot ?? process.cwd();\n  const packageJsonPath = path.join(workspaceRoot, 'package.json');\n  if (!existsSync(packageJsonPath)) {\n    throw new Error('Could not find a package.json. Are you in a Node project?');\n  }\n\n  const rawJson = readFileSync(packageJsonPath, 'utf8');\n  const packageJsonContent = JSON.parse(rawJson) as PackageManifest;\n\n  const getDependencies = (deps: Record<string, string> | undefined) =>\n    Object.entries(deps ?? {}).map(([name, range]) => [name, range] as const);\n\n  const allRawDeps = [\n    ...getDependencies(packageJsonContent.dependencies),\n    ...getDependencies(packageJsonContent.devDependencies),\n    ...getDependencies(packageJsonContent.peerDependencies),\n  ];\n\n  const npmDeps = new Map(\n    allRawDeps.filter(([name, specifier]) => {\n      try {\n        return isPkgFromRegistry(name, specifier);","sourceCodeStart":854,"sourceCodeEnd":890,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/update/update-resolver.ts#L854-L890","documentation":"Thrown at the start of building the update plan when no package.json exists at the workspace root (options.workspaceRoot or process.cwd()). ng update requires a Node project root to read dependencies from, so it aborts immediately.","triggerScenarios":"Running `ng update` outside any Node/JavaScript project directory; wrong --workspace-root (or CWD) pointing at an empty folder; package.json deleted or renamed; running from a subdirectory without workspace root detection.","commonSituations":"Running the command in a fresh terminal opened at the home directory; CI step with incorrect working directory; monorepo where the CLI was invoked from a non-root folder without the workspace flag.","solutions":["cd into the directory containing package.json (usually the repo root) and rerun.","Pass the correct root explicitly: ng update --workspace-root /path/to/project.","Create a package.json if this genuinely is a Node project (npm init).","Verify the file exists: ls package.json in the directory you run from."],"exampleFix":"// before\n~/projects $ ng update   # no package.json here\n// after\ncd ~/projects/my-app\nng update","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport { resolve } from 'path';\nif (!existsSync(resolve(workspaceRoot ?? process.cwd(), 'package.json'))) {\n  throw new Error('Not a Node project root: package.json missing');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngUpdate(packages);\n} catch (e) {\n  if (e.message.includes('Could not find a package.json')) {\n    // retry with an explicit workspace root pointing at the project directory\n  }\n}","preventionTips":["Run ng update from the directory containing package.json.","Set --workspace-root explicitly in CI scripts.","Never rename or delete package.json while tooling runs.","Check `pwd` when a fresh shell reports odd failures."],"tags":["angular-cli","cwd","package-json","workspace"],"backgroundTag":"package-json-not-found","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}