react module_error ai_generated true

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

ID: react/missing-export-default-component

Also available as: JSON · Markdown · 中文
92%Fix Rate
85%Confidence
1Evidence
2023-04-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
webpack 5.88.0 active
create-react-app 5.0.1 active
vite 4.4.0 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 95% success 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"'.
    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. 90% success 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).
    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. 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).

Dead Ends

Common approaches that don't work:

  1. 95% fail

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

  2. 80% fail

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