模块有 否 exported 成员 'X'
错误信息
模块有 否 exported 成员
快速摘要
你 tried 到导入 name 从模块, 但模块 doesn't 导出任何事使用那个 name. 导入 doesn't match 任何导出.
为什么发生
Typo in imported name
导出是 renamed or 移除
Importing 类型那个仅 exists in .d.ts file 那个 isn't 找到
默认对比 named 导入 mismatch
最小示例
✗ 错误代码
import { Usr } from "./types"; // typo: should be User✓ 修复代码
import { User } from "./types";Fix typo: 'Usr' 应该是 '用户'.
如何诊断
检查 spelling 的 imported name
打开源 模块 and 验证导出 exists
检查如果它's 默认导出 (use
导入 X 从不导入 { X } 从)验证模块 path 是正确
如何修复
Fix typo in 导入 name
更新导入到 match current 导出 name
Use 默认导入语法 for 默认导出
添加 re-导出如果 name exists in sub-模块
如何预防
Use IDE auto-导入 features 到 avoid typos
运行 ESLint 使用导入/否-unresolved 规则
Keep 导入组织使用 auto-排序