angular/angular-cli · error · Error

Unknown schematics built-in module '${id}' requested from sc

Error message

Unknown schematics built-in module '${id}' requested from schematic '${schematicFile}'

What it means

customRequire in SchematicEngineHost resolves special module ids requested by schematics. Ids starting with 'schematics:' refer to schematics built-in modules resolved via loadBuiltinModule. When the requested builtin id is not registered, the engine throws 'Unknown schematics built-in module'. This guards against schematics importing modules the host does not provide.

Source

Thrown at packages/angular/cli/src/command-builder/utilities/schematic-engine-host.ts:154

function wrap(
  schematicFile: string,
  schematicDirectory: string,
  moduleCache: Map<string, unknown>,
  exportName?: string,
): () => unknown {
  const hostRequire = createRequire(__filename);
  const schematicRequire = createRequire(schematicFile);

  const customRequire = function (id: string) {
    if (legacyModules[id]) {
      // Provide compatibility modules for older versions of @angular/cdk
      return legacyModules[id];
    } else if (id.startsWith('schematics:')) {
      // Schematics built-in modules use the `schematics` scheme (similar to the Node.js `node` scheme)
      const builtinId = id.slice(11);
      const builtinModule = loadBuiltinModule(builtinId);
      if (!builtinModule) {
        throw new Error(
          `Unknown schematics built-in module '${id}' requested from schematic '${schematicFile}'`,
        );
      }

      return builtinModule;
    } else if (id.startsWith('@angular-devkit/') || id.startsWith('@schematics/')) {
      // Files should not redirect `@angular/core` and instead use the direct
      // dependency if available. This allows old major version migrations to continue to function
      // even though the latest major version may have breaking changes in `@angular/core`.
      if (id.startsWith('@angular-devkit/core')) {
        try {
          return schematicRequire(id);
        } catch (e) {
          assertIsError(e);
          if (e.code !== 'MODULE_NOT_FOUND') {
            throw e;
          }
        }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Correct the import path to a supported builtin (e.g. '@schematics/angular/utility/...' as a normal npm module import instead of 'schematics:...').
  2. Check the CLI version's SchematicEngineHost/loadBuiltinModule to see which 'schematics:' ids are supported, and pin the CLI version the schematic was written for.
  3. If you own the schematic, replace 'schematics:xyz' imports with direct imports from published packages like '@schematics/angular' or '@angular-devkit/schematics'.
  4. Report/upgrade the third-party schematic package to a release compatible with your Angular CLI.

Example fix

// before (in schematic source)
const { getWorkspace } = require('schematics:utility/config');

// after
import { getWorkspace } from '@schematics/angular/utility/config';
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_BUILTINS = new Set(['@angular-devkit/core', /* ids exposed by loadBuiltinModule */]);
function isKnownBuiltin(id: string): boolean {
  return id.startsWith('schematics:') && SUPPORTED_BUILTINS.has(id.slice(11));
}
if (!isKnownBuiltin(moduleId)) {
  throw new Error(`Unsupported schematics: import '${moduleId}'; import from a published package instead`);
}

Type guard

function isSchematicsBuiltinId(id: string): id is `schematics:${string}` {
  return typeof id === 'string' && id.startsWith('schematics:');
}

Try / catch

try {
  require(moduleId);
} catch (e) {
  if (String(e.message).includes('Unknown schematics built-in module')) {
    console.error(`Replace '${moduleId}' with a normal import from @schematics/angular or @angular-devkit/*`);
  } else { throw e; }
}

Prevention

When it happens

Trigger: A schematic source file contains a dynamic or static import of 'schematics:<something>' where <something> is not one of the builtins exposed by loadBuiltinModule — e.g. a typo like require('schematics:utility/help') or an import of a builtin that was removed in the current CLI version.

Common situations: Third-party or hand-written schematics importing 'schematics:...' paths that worked in older Angular CLI versions but whose builtin mapping changed; typos in the module path; copying internal code that used non-public 'schematics:' imports.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/312e412611647dfd. Report an issue: GitHub.