react module_error ai_generated true

尝试导入错误:'ComponentName' 未从 './module' 中导出

Attempted import error: 'ComponentName' is not exported from './module'

ID: react/missing-export-default-component

其他格式: JSON · Markdown 中文 · English
92%修复率
85%置信度
1证据数
2023-04-15首次发现

版本兼容性

版本状态引入弃用备注
webpack 5.88.0 active — — —
create-react-app 5.0.1 active — — —
vite 4.4.0 active — — —

根因分析

导入语句中引用的组件或函数要么未导出,要么以默认方式导出但作为命名导入,或者文件路径错误。

English

Component or function referenced in import statement is either not exported, exported as default but imported as named, or the file path is incorrect.

generic

官方文档

https://webpack.js.org/guides/tree-shaking/

解决方案

  1. Check the export statement in the module file. If it uses 'export default ComponentName', use default import: 'import ComponentName from "./module"'. If it uses 'export { ComponentName }', use named import: 'import { ComponentName } from "./module"'.
  2. Verify the file path relative to the importing file. Use './' for same directory, '../' for parent. Ensure file extension is omitted or correct (webpack handles .js/.jsx/.ts/.tsx).

无效尝试

常见但无效的做法:

  1. 95% 失败

    The error is static; restarting doesn't change the module's export statements.

  2. 80% 失败

    If the import uses named syntax, adding default export doesn't fix it; may cause export ambiguity.