abpframework/abp · error · CliUsageException
package.json file not found
Error message
package.json file not found
What it means
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.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/Angular/AngularServiceProxyGenerator.cs:105
var serviceType = GetServiceType(args) ?? Volo.Abp.Cli.ServiceProxying.ServiceType.Application;
commandBuilder.Append($" --service-type {serviceType.ToString().ToLowerInvariant()}");
_cmdhelper.RunCmd(commandBuilder.ToString());
}
protected override ServiceType? GetDefaultServiceType(GenerateProxyArgs args)
{
return ServiceType.Application;
}
private async Task CheckNgSchematicsAsync()
{
var packageJsonPath = $"package.json";
if (!File.Exists(packageJsonPath))
{
throw new CliUsageException(
"package.json file not found"
);
}
var schematicsVersion =
(string)JObject.Parse(File.ReadAllText(packageJsonPath))["devDependencies"]?["@abp/ng.schematics"];
if (schematicsVersion == null)
{
throw new CliUsageException(
"\"@abp/ng.schematics\" NPM package should be installed to the devDependencies before running this command!"
);
}
var parsed = SemanticVersion.TryParse(schematicsVersion.TrimStart('~', '^', 'v'), out var semanticSchematicsVersion);
if (!parsed)
{
Logger.LogWarning("Couldn't determinate version of \"@abp/ng.schematics\" package.");View on GitHub (pinned to 7ed43b1931)
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>'.
Example fix
// before (run from repo root) abp generate-proxy -t ng // after cd angular/ abp generate-proxy -t ng
Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists("package.json"))
{ Console.Error.WriteLine("Run this command from the Angular project root (no package.json here)."); return; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Wrong working directory; running the proxy command from the .Http.Host project; new clone where the developer has not navigated into the angular/ folder.
Related errors
- angular.json file not found. You must run this command in th
- "@abp/ng.schematics" NPM package should be installed to the
- Specified directory does not exist.
- No project file(csproj) found in the directory.
- Option folder should be a directory.
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/454b7eadee38f3b8.
Report an issue: GitHub.