{"record":{"id":"5f4492d607796aa4","repo":"angular/angular-cli","slug":"collection-json-stringify-name-cannot-be-resol","errorCode":null,"errorMessage":"Collection ${JSON.stringify(name)} cannot be resolved.","messagePattern":"Collection (.+?) cannot be resolved\\.","errorType":"exception","errorClass":"CollectionCannotBeResolvedException","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/schematics/tools/file-system-engine-host.ts","lineNumber":48,"sourceCode":"\n  protected _resolveCollectionPath(name: string): string {\n    try {\n      // Allow `${_root}/${name}.json` as a collection.\n      const maybePath = require.resolve(join(this._root, name + '.json'));\n      if (existsSync(maybePath)) {\n        return maybePath;\n      }\n    } catch (error) {}\n\n    try {\n      // Allow `${_root}/${name}/collection.json.\n      const maybePath = require.resolve(join(this._root, name, 'collection.json'));\n      if (existsSync(maybePath)) {\n        return maybePath;\n      }\n    } catch (error) {}\n\n    throw new CollectionCannotBeResolvedException(name);\n  }\n\n  protected _resolveReferenceString(\n    refString: string,\n    parentPath: string,\n  ): { ref: RuleFactory<{}>; path: string } | null {\n    // Use the same kind of export strings as NodeModule.\n    const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);\n    if (!ref.ref) {\n      return null;\n    }\n\n    return { ref: ref.ref, path: ref.module };\n  }\n\n  protected _transformCollectionDescription(\n    name: string,\n    desc: Partial<FileSystemCollectionDesc>,","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/schematics/tools/file-system-engine-host.ts#L30-L66","documentation":"Thrown by _resolveCollectionPath in FileSystemEngineHost when a collection.json cannot be located for the given name. The host tries require.resolve('<root>/<name>/collection.json') and falls through to this exception when resolution fails or the file does not exist.","triggerScenarios":"Calling engine.createCollection(name) where <root>/<name>/collection.json does not exist; a misspelled collection name; running outside a directory containing node_modules with the target package installed.","commonSituations":"ng generate with a collection package not installed (forgot npm install); a private package name typo in --collection; working in a repo where the local collection is not linked/built; requiring the engine with a _root that doesn't point to a node_modules directory.","solutions":["Install the collection package: npm install <collection-name> (or link it locally with npm link).","Verify the package ships a collection.json at its root and the name passed matches the package name exactly.","Check the engine's _root — construct the FileSystemEngineHost with the correct base path for resolution.","If using a local collection, build it and point the engine root at the directory containing it."],"exampleFix":"// before (package not installed)\nconst engine = new FileSystemEngineHost(process.cwd());\nengine.createCollection('@myorg/schematics'); // throws\n// after\n// npm install @myorg/schematics\nconst engine = new FileSystemEngineHost(path.join(process.cwd(), 'node_modules'));\nengine.createCollection('@myorg/schematics');","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport { join } from 'path';\nconst root = join(process.cwd(), 'node_modules');\nconst p = join(root, name, 'collection.json');\nif (!existsSync(p)) throw new Error(`Collection '${name}' not installed (expected ${p}); run npm install ${name}`);","typeGuard":null,"tryCatchPattern":"try {\n  const collection = engine.createCollection(name);\n} catch (e) {\n  if (String(e.message).includes('cannot be resolved')) {\n    console.error(`Install '${name}' or fix the engine root path`);\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Add schematic collection packages to devDependencies so they are always installed.","Use npm link / workspace references while developing local collections, and build before use.","Confirm package names with `npm ls` before passing them to createCollection."],"tags":["schematics","module-resolution","missing-package"],"backgroundTag":"collection-cannot-be-resolved","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}