{"record":{"id":"454b7eadee38f3b8","repo":"abpframework/abp","slug":"package-json-file-not-found","errorCode":null,"errorMessage":"package.json file not found","messagePattern":"package\\.json file not found","errorType":"exception","errorClass":"CliUsageException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs","lineNumber":105,"sourceCode":"        var serviceType = GetServiceType(args) ?? Volo.Abp.Cli.ServiceProxying.ServiceType.Application;\n        commandBuilder.Append($\" --service-type {serviceType.ToString().ToLowerInvariant()}\");\n\n\n        _cmdhelper.RunCmd(commandBuilder.ToString());\n    }\n\n    protected override ServiceType? GetDefaultServiceType(GenerateProxyArgs args)\n    {\n        return ServiceType.Application;\n    }\n\n    private async Task CheckNgSchematicsAsync()\n    {\n        var packageJsonPath = $\"package.json\";\n\n        if (!File.Exists(packageJsonPath))\n        {\n            throw new CliUsageException(\n                \"package.json file not found\"\n            );\n        }\n\n        var schematicsVersion =\n            (string)JObject.Parse(File.ReadAllText(packageJsonPath))[\"devDependencies\"]?[\"@abp/ng.schematics\"];\n\n        if (schematicsVersion == null)\n        {\n            throw new CliUsageException(\n                \"\\\"@abp/ng.schematics\\\" NPM package should be installed to the devDependencies before running this command!\"\n            );\n        }\n\n        var parsed = SemanticVersion.TryParse(schematicsVersion.TrimStart('~', '^', 'v'), out var semanticSchematicsVersion);\n        if (!parsed)\n        {\n            Logger.LogWarning(\"Couldn't determinate version of \\\"@abp/ng.schematics\\\" package.\");","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs#L87-L123","documentation":"AngularServiceProxyGenerator.CheckNgSchematicsAsync checks for a 'package.json' in the current working directory and throws a CliUsageException if File.Exists returns false. The Angular proxy generator ('abp generate-proxy -t ng' / ServiceType.Angular) must run from the Angular application root where package.json lives.","triggerScenarios":"Running 'abp generate-proxy -t ng' from outside the Angular project (e.g. repo root, server project folder, or backend folder). The generator uses a relative 'package.json' path with no fallback.","commonSituations":"Wrong working directory; running the proxy command from the .Http.Host project; new clone where the developer has not navigated into the angular/ folder.","solutions":["cd into the Angular application folder (typically the angular/ subfolder of the solution) before running the command.","Confirm 'package.json' is present with 'ls package.json'.","Re-run: 'abp generate-proxy -t ng -u <app-name> --url <backend-url>'."],"exampleFix":"// before (run from repo root)\nabp generate-proxy -t ng\n// after\ncd angular/\nabp generate-proxy -t ng","handlingStrategy":"validation","validationCode":"if (!File.Exists(\"package.json\"))\n{ Console.Error.WriteLine(\"Run this command from the Angular project root (no package.json here).\"); return; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always cd into the angular/ folder before running Angular proxy generation.","Add a wrapper script that checks for package.json and angular.json before invoking abp."],"tags":["cli","service-proxy","angular","working-directory","argument-validation"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}