{"record":{"id":"7450c1e7c8b0f1e7","repo":"shadcn-ui/ui","slug":"could-not-resolve-the-icon-import-for-sourcelibr","errorCode":null,"errorMessage":"Could not resolve the icon import for ${sourceLibrary.title}.","messagePattern":"Could not resolve the icon import for (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/shadcn/src/migrations/migrate-icons.ts","lineNumber":314,"sourceCode":"\n  return result.content\n}\n\nexport async function migrateIconsFileWithReport(\n  content: string,\n  sourceLibraryName: MigrationIconLibraryName,\n  targetLibraryName: MigrationIconLibraryName,\n  iconsMapping: IconsMapping\n): Promise<{ content: string; skipped: SkippedIcon[] }> {\n  const sourceLibrary = MIGRATION_ICON_LIBRARIES[sourceLibraryName]\n  const targetLibrary = MIGRATION_ICON_LIBRARIES[targetLibraryName]\n\n  const sourceIconModule = getIconModuleSpecifier(sourceLibrary.import)\n  const sourceUsage = parseUsageTemplate(sourceLibrary.usage)\n  const targetUsage = parseUsageTemplate(targetLibrary.usage)\n\n  if (!sourceIconModule) {\n    throw new Error(\n      `Could not resolve the icon import for ${sourceLibrary.title}.`\n    )\n  }\n\n  const reverseIndex = buildReverseIconIndex(iconsMapping, sourceLibraryName)\n  const skipped: SkippedIcon[] = []\n\n  const dir = await fs.mkdtemp(path.join(tmpdir(), \"shadcn-\"))\n  const project = new Project({\n    compilerOptions: {},\n  })\n\n  const tempFile = path.join(\n    dir,\n    `shadcn-icons-${randomBytes(4).toString(\"hex\")}.tsx`\n  )\n  const sourceFile = project.createSourceFile(tempFile, content, {\n    scriptKind: ScriptKind.TSX,","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/shadcn-ui/ui/blob/efac5987074af84ece57c367c6dd83387b967022/packages/shadcn/src/migrations/migrate-icons.ts#L296-L332","documentation":"Thrown inside migrateIconsFileWithReport when getIconModuleSpecifier(sourceLibrary.import) returns undefined. getIconModuleSpecifier scans the parsed import template for a named import containing the literal token 'ICON'; if no such named import exists it returns undefined, meaning the migrator cannot locate the module to scan source files against. This indicates a malformed library entry in MIGRATION_ICON_LIBRARIES rather than a user file problem.","triggerScenarios":"A MIGRATION_ICON_LIBRARIES entry whose `import` template omits the ICON token (e.g. a wrapper-only import with no placeholder); a custom/patched iconLibraries export that broke the import template contract; source library is a wrapper-style library whose import template was edited to drop ICON.","commonSituations":"Forked shadcn with a custom icon library added incorrectly; upstream regression in iconLibraries; user passed an invalid sourceLibraryName that nonetheless indexed an incomplete entry.","solutions":["If you maintain a custom MIGRATION_ICON_LIBRARIES entry, ensure its `import` field contains the ICON placeholder, e.g. \"import { ICON } from 'my-icons'\".","Upgrade shadcn — this usually indicates a regression in a bundled library definition.","Report the issue upstream with the sourceLibraryName that triggered it."],"exampleFix":"// before — custom library entry missing ICON placeholder\nmyicons: {\n  import: \"import { IconWrapper } from 'my-icons'\",\n  usage: \"<IconWrapper icon={...} />\"\n}\n\n// after — include the ICON token so getIconModuleSpecifier can resolve\nmyicons: {\n  import: \"import { ICON, IconWrapper } from 'my-icons'\",\n  usage: \"<IconWrapper icon={ICON} />\"\n}","handlingStrategy":"validation","validationCode":"import { getIconModuleSpecifier } from '@/src/icons/templates'\nimport { MIGRATION_ICON_LIBRARIES } from '@/src/migrations/migrate-icons'\n\nfunction assertLibraryImportResolvable(name: MigrationIconLibraryName) {\n  const lib = MIGRATION_ICON_LIBRARIES[name]\n  if (!getIconModuleSpecifier(lib.import)) {\n    throw new Error(`Library '${name}' has a malformed import template (missing ICON token).`)\n  }\n}\n\nassertLibraryImportResolvable(sourceLibraryName)","typeGuard":"function isResolvableLibrary(lib: { import: string }): boolean {\n  return Boolean(getIconModuleSpecifier(lib.import))\n}","tryCatchPattern":null,"preventionTips":["When forking/adding a library to MIGRATION_ICON_LIBRARIES, always include the ICON token in the import template.","Add a unit test that asserts getIconModuleSpecifier is non-null for every bundled library.","Treat this error as an upstream bug — report it rather than working around it."],"tags":["migration","icons","config","internal","template"],"backgroundTag":null,"analyzedSha":"efac5987074af84ece57c367c6dd83387b967022","analyzedAt":"2026-08-12T05:00:50.218Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}