angular/angular-cli · error · NodePackageDoesNotSupportSchematics

Package ${JSON.stringify(name)} was found but does not suppo

Error message

Package ${JSON.stringify(name)} was found but does not support schematics.

What it means

The NodeModuleEngineHost resolved the requested package successfully (require.resolve found it), but the package's package.json either lacks a "schematics" field or that field is not a string. The schematics field is what tells the engine which JSON collection file describes the package's schematics, so without it the package cannot be used as a schematic collection. This error is thrown from resolve() in packages/angular_devkit/schematics/tools/node-module-engine-host.ts:60 via NodePackageDoesNotSupportSchematics.

Source

Thrown at packages/angular_devkit/schematics/tools/node-module-engine-host.ts:60

          'Circular schematic reference detected: ' + JSON.stringify(Array.from(references)),
        );
      } else {
        references.add(requester);
      }
    }

    let collectionPath: string | undefined = undefined;
    const resolveOptions = {
      paths: requester ? [dirname(requester), ...(this.paths || [])] : this.paths,
    };

    // Try to resolve as a package
    try {
      const packageJsonPath = require.resolve(`${name}/package.json`, resolveOptions);
      const { schematics } = require(packageJsonPath);

      if (!schematics || typeof schematics !== 'string') {
        throw new NodePackageDoesNotSupportSchematics(name);
      }

      // If this is a relative path to the collection, then create the collection
      // path in relation to the package path
      if (schematics.startsWith('.')) {
        const packageDirectory = dirname(packageJsonPath);
        collectionPath = resolve(packageDirectory, schematics);
      }
      // Otherwise treat this as a package, and recurse to find the collection path
      else {
        collectionPath = this.resolve(schematics, packageJsonPath, references);
      }
    } catch (e) {
      if ((e as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {
        throw e;
      }
    }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Add a valid "schematics" entry to the package's package.json, e.g. "schematics": "./schematics/collection.json", pointing at a real JSON collection file.
  2. Verify you installed the correct package — many libraries ship schematics in a separate package (e.g. `/schematics` variant); use that package name in your schematic/collection reference.
  3. If using npm "exports", ensure "./package.json" is exported so require.resolve(`${name}/package.json`) and the require() read the correct file.
  4. Double-check the field is a string (a path), not an object; fix typos like "schematic" or "schematicsPath".

Example fix

// before (package.json of the target package)
{
  "name": "my-lib",
  "version": "1.0.0"
}
// after
{
  "name": "my-lib",
  "version": "1.0.0",
  "schematics": "./schematics/collection.json"
}
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function supportsSchematics(name) {
  try {
    const pkg = require(require.resolve(`${name}/package.json`));
    return typeof pkg.schematics === 'string';
  } catch {
    return false;
  }
}
if (!supportsSchematics('my-lib')) throw new Error('package has no schematics collection');

Type guard

function hasSchematicsField(pkg) {
  return typeof pkg === 'object' && pkg !== null && typeof pkg.schematics === 'string';
}

Try / catch

try {
  const collection = host.createCollection(name);
} catch (err) {
  if (err instanceof NodePackageDoesNotSupportSchematics) {
    console.error(`${name} is not a schematics package; check its package.json "schematics" field`);
  } else { throw err; }
}

Prevention

When it happens

Trigger: Calling createSchematicCollection/get/create a collection whose name is a resolvable npm package, where require(`${name}/package.json`).schematics is undefined or not a string — e.g. `ng generate`/`ng add` pointed at a normal (non-schematic) npm package, or a schematics package whose package.json is missing the "schematics": "./schematics.json" entry.

Common situations: Running `ng add <some-package>` on a library that has no schematics support; publishing a schematics collection but forgetting the "schematics" key in package.json; typo'ing the field name ("schematic" instead of "schematics"); installing the wrong package (core library instead of its schematics companion package); a package.json exports map preventing `${name}/package.json` from exposing the intended file.

Related errors


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