angular/angular-cli · error · Error
The "not" keyword is not supported in JSON Schema.
Error message
The "not" keyword is not supported in JSON Schema.
What it means
The CLI converts a command's JSON Schema into yargs options. JSON Schema's 'not' keyword (and by extension schemas using it) cannot be represented as positive yargs constraints, so the schema visitor throws when it encounters a '/not/' JSON pointer.
Source
Thrown at packages/angular/cli/src/command-builder/utilities/json-schema.ts:329
const options: Option[] = [];
function visitor(
current: json.JsonObject | json.JsonArray,
pointer: json.schema.JsonPointer,
parentSchema?: json.JsonObject | json.JsonArray,
) {
if (
!parentSchema ||
json.isJsonArray(current) ||
pointer.split(/\/(?:properties|items|definitions)\//g).length > 2
) {
// Ignore root, arrays, and subitems.
return;
}
if (pointer.includes('/not/')) {
// We don't support anyOf/not.
throw new Error('The "not" keyword is not supported in JSON Schema.');
}
const ptr = json.schema.parseJsonPointer(pointer);
if (ptr[ptr.length - 2] !== 'properties') {
// Skip any non-property items.
return;
}
const name = ptr.at(-1) as string;
const types = getSupportedTypes(current);
if (types.length === 0) {
// This means it's not usable on the command line. e.g. an Object.
return;
}
const [type] = types;
const $default = current.$default;View on GitHub (pinned to bb72145f9a)
Solutions
- Rewrite the schematic's schema.json to avoid 'not' (use enum/const/pattern with inverse semantics instead)
- Replace {"not": {...}} with explicit allowed values, e.g. enum listing valid inputs
- If it's a third-party schematic, report/upgrade to a version compatible with the CLI's schema parser
- Pin the CLI version that accepted the schema while migrating
Example fix
// before (schema.json)
{"type":"string","not":{"enum":["forbidden"]}}
// after
{"type":"string","enum":["allowed-a","allowed-b"]} Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from 'fs';
const schema = JSON.parse(readFileSync(schemaPath, 'utf8'));
function usesNotKeyword(schema: unknown): boolean {
return JSON.stringify(schema).includes('"not"');
}
if (usesNotKeyword(schema)) {
console.warn('Schema uses unsupported "not" keyword for CLI option parsing');
} Try / catch
try {
await ngGenerate(schematic, options);
} catch (e) {
if ((e as Error).message.includes('"not" keyword')) {
console.error('Schematic schema uses JSON Schema "not"; upgrade the schematic package.');
} else throw e;
} Prevention
- Author schematic schemas with only enum/const/pattern/allOf/anyOf (no 'not')
- Test custom schematics against the CLI version you ship with
- Prefer explicit allowed-value lists over negation in builder schemas
When it happens
Trigger: A schematic or command defines its schema.json with a 'not' keyword on a property; invoking 'ng g' or a command whose builder schema uses 'not'/'anyOf'+'not' composition.
Common situations: Custom/community schematics authored with advanced JSON Schema keywords; upgrading a schematic to a newer CLI that no longer tolerates 'not'; hand-written strict validation in a builder schema.
Related errors
- schematicName cannot be undefined.
- Could not find (/.angular.json)
- Unknown schematics built-in module '${id}' requested from sc
- A collection and schematic is required during execution.
- Unknown task dependency [ID: ${id.id}].
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/ff40bcd1f8c3f576.
Report an issue: GitHub.