abpframework/abp · error · CliUsageException
Angular library name can not be empty
Error message
Angular library name can not be empty
What it means
Thrown by ProjectCreationCommandBase.CreateAngularLibraryAsync when the libraryName parameter is null or whitespace. This method generates an Angular library using the ABP schematics (npx ng g @abp/ng.schematics:create-lib) and requires a valid package name. The code marks the validation with a TODO suggesting it could be improved.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs:796
var libraryName = projectArgs.SolutionName.ProjectName.ToKebabCase();
var angularAppPath = Path.Combine(rootPath, "apps", "angular");
var result = await CreateAngularLibraryAsync(libraryName, angularAppPath);
Logger.LogInformation(result);
}
protected virtual async Task<string> CreateAngularLibraryAsync(
string libraryName,
string workingDirectory,
bool isSecondaryEndpoint = false,
bool isModuleTemplate = true,
bool isOverride = true)
{
//TODO: Can we improve this validations ?
if (string.IsNullOrWhiteSpace(libraryName))
{
throw new CliUsageException("Angular library name can not be empty");
}
if (string.IsNullOrWhiteSpace(workingDirectory))
{
throw new CliUsageException("Angular project path can not be empty");
}
var commandBuilder = new StringBuilder($"npx ng g @abp/ng.schematics:create-lib --package-name {libraryName}");
commandBuilder.Append($" --is-secondary-entrypoint {isSecondaryEndpoint.ToString().ToLowerInvariant()}");
commandBuilder.Append($" --is-module-template {isModuleTemplate.ToString().ToLowerInvariant()}");
commandBuilder.Append($" --override {isOverride.ToString().ToLowerInvariant()}");
var result = CmdHelper.RunCmdAndGetOutput(commandBuilder.ToString(), workingDirectory);
return await Task.FromResult(result);
}
public static class OptionsView on GitHub (pinned to 7ed43b1931)
Solutions
- Ensure the module or entity name (from which the Angular library name is derived) is provided and non-empty
- Pass an explicit, non-empty library name that follows npm package naming conventions (e.g., @mycompany/my-lib)
- Check upstream: if the name comes from commandLineArgs.Target or a module parameter, ensure that was supplied
Example fix
// before
await CreateAngularLibraryAsync("", workingDir);
// after
await CreateAngularLibraryAsync("@mycompany/feature-lib", workingDir); Defensive patterns
Strategy: validation
Validate before calling
// Validate the Angular library name before calling CreateAngularLibraryAsync
if (string.IsNullOrWhiteSpace(libraryName))
{
Console.Error.WriteLine("Error: Angular library name cannot be empty. Derive it from the module name.");
return;
}
// Also validate npm package name format
if (!Regex.IsMatch(libraryName, @"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"))
{
Console.Error.WriteLine($"Error: '{libraryName}' is not a valid npm package name.");
return;
} Type guard
// Type guard for non-empty, npm-valid library name
static bool IsValidAngularLibraryName(string? name) =>
!string.IsNullOrWhiteSpace(name) &&
Regex.IsMatch(name, @"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"); Try / catch
try
{
await CreateAngularLibraryAsync(libraryName, workingDirectory);
}
catch (CliUsageException ex) when (ex.Message.Contains("Angular library name can not be empty"))
{
logger.LogError("Library name was empty. Ensure the module/entity name is provided.");
} Prevention
- Ensure the module or entity name (source of the library name) is provided and non-empty
- Validate the name follows npm package naming conventions before passing it
- Guard the upstream call site that derives the library name from user input
When it happens
Trigger: Calling CreateAngularLibraryAsync with an empty/null library name. This typically happens when the caller derives the library name from a module or entity name that was not provided, or from a template variable that resolved to empty.
Common situations: During module template generation where the module/entity name is missing or empty, causing the derived Angular library name to be empty. Also from programmatic API misuse where the caller does not validate before invoking. The TODO comment indicates the validation is considered incomplete.
Related errors
- Project name is missing!
- DbMigrations folder path is missing!
- Module name is missing!
- Specified directory does not exist.
- Username name is missing!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/124279a5ab6e2d15.
Report an issue: GitHub.