react
module_error
ai_generated
true
尝试导入错误:'ComponentName' 未从 './module' 中导出
Attempted import error: 'ComponentName' is not exported from './module'
ID: react/missing-export-default-component
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.
官方文档
https://webpack.js.org/guides/tree-shaking/解决方案
-
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"'. -
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).
无效尝试
常见但无效的做法:
-
95% 失败
The error is static; restarting doesn't change the module's export statements.
-
80% 失败
If the import uses named syntax, adding default export doesn't fix it; may cause export ambiguity.