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

  1. cd into the Angular application folder (typically the angular/ subfolder of the solution) before running the command.
  2. Confirm 'package.json' is present with 'ls package.json'.
  3. 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

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


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/454b7eadee38f3b8. Report an issue: GitHub.