{"record":{"id":"bc74c1b8443aa76e","repo":"angular/angular-cli","slug":"could-not-find-version","errorCode":null,"errorMessage":"Could not find version.","messagePattern":"Could not find version\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/server/index.ts","lineNumber":145,"sourceCode":"    if (!Array.isArray(include) || !include.includes('src/**/*.ts')) {\n      const filesPath = ['files'];\n      const files = new Set((json.get(filesPath) as string[] | undefined) ?? []);\n      files.add('src/' + serverMainEntryName);\n      json.modify(filesPath, [...files]);\n    }\n\n    const typePath = ['compilerOptions', 'types'];\n    const types = new Set((json.get(typePath) as string[] | undefined) ?? []);\n    types.add('node');\n    json.modify(typePath, [...types]);\n  };\n}\n\nfunction addDependencies(skipInstall: boolean | undefined): Rule {\n  return (host: Tree) => {\n    const coreDep = getPackageJsonDependency(host, '@angular/core');\n    if (coreDep === null) {\n      throw new SchematicsException('Could not find version.');\n    }\n\n    const install = skipInstall ? InstallBehavior.None : InstallBehavior.Auto;\n\n    return chain([\n      addDependency('@angular/ssr', latestVersions.AngularSSR, {\n        type: DependencyType.Default,\n        install,\n      }),\n      addDependency('@angular/platform-server', coreDep.version, {\n        type: DependencyType.Default,\n        install,\n      }),\n      addDependency('@types/node', latestVersions['@types/node'], {\n        type: DependencyType.Dev,\n        install,\n      }),\n    ]);","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/server/index.ts#L127-L163","documentation":"Thrown by the server schematic's addDependencies when @angular/core cannot be found in the host's package.json dependencies, so its version cannot be read to align @angular/ssr with the framework version.","triggerScenarios":"Running `ng generate @angular/ssr:server` (or the server schematic Rule) in a workspace whose package.json lacks @angular/core in dependencies, or where getPackageJsonDependency returns null due to malformed package.json.","commonSituations":"Generating into a directory outside a proper Angular app; package.json manually stripped of dependencies; running the schematic in a bare/empty tree during tests; corrupted package.json JSON.","solutions":["Ensure @angular/core is present in package.json dependencies (`npm i @angular/core`), then re-run the schematic.","Run the schematic from the workspace root where the Angular app's package.json lives.","Validate package.json parses (e.g. `npm pkg get dependencies`).","Add @angular/ssr manually with `ng add @angular/ssr` if dependency installation is problematic."],"exampleFix":"// before (package.json)\n\"dependencies\": { \"@angular/common\": \"^18.0.0\" }\n// after\n\"dependencies\": { \"@angular/core\": \"^18.0.0\", \"@angular/common\": \"^18.0.0\" }","handlingStrategy":"validation","validationCode":"const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));\nif (!pkg.dependencies?.['@angular/core']) {\n  throw new Error('@angular/core must be a dependency before running the server schematic.');\n}","typeGuard":"function hasCoreDep(pkg: { dependencies?: Record<string, string> }): boolean {\n  return typeof pkg.dependencies?.['@angular/core'] === 'string';\n}","tryCatchPattern":"try {\n  await generateServerSchematic(options);\n} catch (e) {\n  if (String(e.message).includes('Could not find version')) {\n    console.error('Install @angular/core first, then re-run.');\n  } else throw e;\n}","preventionTips":["Always scaffold via ng new / ng add so dependencies are complete","Never hand-strip @angular/core from package.json","Run schematics from the workspace root","Validate package.json parses before codegen steps"],"tags":["angular","schematics","dependencies","package-json"],"backgroundTag":"missing-peer-dependency","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}