shadcn-ui/ui · error
Could not resolve the icon import for ${sourceLibrary.title}
Error message
Could not resolve the icon import for ${sourceLibrary.title}. What it means
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.
Source
Thrown at packages/shadcn/src/migrations/migrate-icons.ts:314
return result.content
}
export async function migrateIconsFileWithReport(
content: string,
sourceLibraryName: MigrationIconLibraryName,
targetLibraryName: MigrationIconLibraryName,
iconsMapping: IconsMapping
): Promise<{ content: string; skipped: SkippedIcon[] }> {
const sourceLibrary = MIGRATION_ICON_LIBRARIES[sourceLibraryName]
const targetLibrary = MIGRATION_ICON_LIBRARIES[targetLibraryName]
const sourceIconModule = getIconModuleSpecifier(sourceLibrary.import)
const sourceUsage = parseUsageTemplate(sourceLibrary.usage)
const targetUsage = parseUsageTemplate(targetLibrary.usage)
if (!sourceIconModule) {
throw new Error(
`Could not resolve the icon import for ${sourceLibrary.title}.`
)
}
const reverseIndex = buildReverseIconIndex(iconsMapping, sourceLibraryName)
const skipped: SkippedIcon[] = []
const dir = await fs.mkdtemp(path.join(tmpdir(), "shadcn-"))
const project = new Project({
compilerOptions: {},
})
const tempFile = path.join(
dir,
`shadcn-icons-${randomBytes(4).toString("hex")}.tsx`
)
const sourceFile = project.createSourceFile(tempFile, content, {
scriptKind: ScriptKind.TSX,View on GitHub (pinned to efac598707)
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.
Example fix
// before — custom library entry missing ICON placeholder
myicons: {
import: "import { IconWrapper } from 'my-icons'",
usage: "<IconWrapper icon={...} />"
}
// after — include the ICON token so getIconModuleSpecifier can resolve
myicons: {
import: "import { ICON, IconWrapper } from 'my-icons'",
usage: "<IconWrapper icon={ICON} />"
} Defensive patterns
Strategy: validation
Validate before calling
import { getIconModuleSpecifier } from '@/src/icons/templates'
import { MIGRATION_ICON_LIBRARIES } from '@/src/migrations/migrate-icons'
function assertLibraryImportResolvable(name: MigrationIconLibraryName) {
const lib = MIGRATION_ICON_LIBRARIES[name]
if (!getIconModuleSpecifier(lib.import)) {
throw new Error(`Library '${name}' has a malformed import template (missing ICON token).`)
}
}
assertLibraryImportResolvable(sourceLibraryName) Type guard
function isResolvableLibrary(lib: { import: string }): boolean {
return Boolean(getIconModuleSpecifier(lib.import))
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Forked shadcn with a custom icon library added incorrectly; upstream regression in iconLibraries; user passed an invalid sourceLibraryName that nonetheless indexed an incomplete entry.
Related errors
- We could not find a valid `ui` path in your `components.json
- Unknown icon library: ${libraryName}. Available libraries: $
- No files found matching: ${options.path}
- Something went wrong fetching the registry icons.
- You cannot migrate to the same icon library. Please choose a
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/7450c1e7c8b0f1e7.
Report an issue: GitHub.