{"record":{"id":"f29b5014e4bdb3f7","repo":"angular/angular-cli","slug":"name-option-is-required","errorCode":null,"errorMessage":"name option is required.","messagePattern":"name option is required\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics_cli/blank/factory.ts","lineNumber":49,"sourceCode":"    const collectionJson = tree.readJson(collectionPath);\n\n    if (!isJsonObject(collectionJson) || !isJsonObject(collectionJson.schematics)) {\n      throw new Error('Invalid collection.json; schematics needs to be an object.');\n    }\n\n    collectionJson['schematics'][schematicName] = description;\n    tree.overwrite(collectionPath, JSON.stringify(collectionJson, undefined, 2));\n  };\n}\n\nexport default function (options: Schema): Rule {\n  const schematicsVersion = require('@angular-devkit/schematics/package.json').version;\n  const coreVersion = require('@angular-devkit/core/package.json').version;\n\n  // Verify if we need to create a full project, or just add a new schematic.\n  return (tree: Tree, context: SchematicContext) => {\n    if (!options.name) {\n      throw new SchematicsException('name option is required.');\n    }\n\n    let collectionPath: Path | undefined;\n    try {\n      const packageJson = tree.readJson('/package.json') as {\n        schematics: unknown;\n      };\n      if (typeof packageJson.schematics === 'string') {\n        const p = normalize(packageJson.schematics);\n        if (tree.exists(p)) {\n          collectionPath = p;\n        }\n      }\n    } catch {}\n\n    let source = apply(url('./schematic-files'), [\n      applyTemplates({\n        ...options,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics_cli/blank/factory.ts#L31-L67","documentation":"The blank schematic requires the 'name' option to decide what to generate (a new schematic within an existing collection, or a full project). If options.name is falsy when the rule executes, it throws this SchematicsException. This is fail-fast validation so the schematic never produces partial or wrong output.","triggerScenarios":"Invoking the blank schematic (e.g. `ng g blank` or the schematics CLI `schematics ...:blank`) without passing --name, or passing --name=\"\" (empty string is falsy and also triggers the throw).","commonSituations":"Running the schematic from a script or npm task that forgot to forward the name argument; interactive prompting disabled in CI; typo in the flag name so it lands in extraOptions instead of options.name; copying a doc example that omitted --name.","solutions":["Rerun the command with a name: e.g. `ng g blank --name=my-schematic` or `schematics @schematics/schematics:blank --name=my-schematic`.","Check your npm script / CI invocation to confirm the --name value is actually forwarded (not swallowed by quoting or an unset shell variable).","Ensure the flag is spelled exactly `--name`; unknown/misspelled flags are ignored rather than mapped to options.name."],"exampleFix":"// before\nnpx schematics @schematics/schematics:blank --dry-run\n\n// after\nnpx schematics @schematics/schematics:blank --name=my-schematic","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nconst nameFlagIdx = args.findIndex(a => a === '--name' || a.startsWith('--name='));\nconst name = nameFlagIdx === -1 ? undefined : args[nameFlagIdx].includes('=') ? args[nameFlagIdx].split('=')[1] : args[nameFlagIdx + 1];\nif (!name) {\n  throw new Error('Provide --name before running the blank schematic.');\n}","typeGuard":"function hasName(o) {\n  return typeof o === 'object' && o !== null && typeof o.name === 'string' && o.name.length > 0;\n}","tryCatchPattern":"try {\n  await schematicRunner.executeBlank({ name: 'my-schematic' });\n} catch (err) {\n  if (err.message === 'name option is required.') {\n    console.error('Missing --name; rerun with e.g. --name=my-schematic');\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always pass --name=<value> when invoking the blank schematic.","Quote argument values in npm scripts and CI so they are not swallowed.","Check flag spelling; unknown flags are ignored and leave options.name undefined.","Avoid passing an empty string as name; it is falsy and triggers the same exception."],"tags":["schematics","cli","missing-option","angular-cli"],"backgroundTag":"missing-required-option","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}