Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

A React component import fails because the file has no export with that name

ErrorHome does not contain an export named Home

Short answer

Import and export must use the same style. A named export is imported with braces and the exact same name. A default export is imported without braces, under any name. The error means the import asks for a named export the file does not have. Add export to the component, or remove the braces from the import.

  • Applies to React 19, Vite current, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the file being imported and look at how its component is exported. Then look at the import line. Braces on one side and none on the other is the usual mismatch.

    grep -n "export" src/Home.jsx
    grep -rn "from './Home'" src/
  2. 2Match what you see, then jump to its fix

    1. 1The file ends with export default Home, and the import reads import { Home } from './Home'The component is a default export but it is imported with bracesFix
    2. 2grep finds no export line for the component in the fileThe component has no export keyword at allFix
    3. 3The file exports a named value, but under another spelling or caseThe imported name differs from the exported nameFix

What does the error look like?

  • Home does not contain an export named Home
  • import { Home } from './Home' fails while the file has export default Home

Cause 1 of 3

The component is a default export but it is imported with braces

1Check

A module can have one default export and any number of named exports. A default export is imported without braces, and the importer may choose any local name.

grep -n "export default" src/Home.jsx
grep -rn "import { Home }" src/

2Fix

Import the default export without braces. As an alternative, make it a named export in the file and keep the braces.

// option A: keep export default, drop the braces
import Home from './Home';

// option B: named export in Home.jsx, keep the braces
export function Home() { /* ... */ }
import { Home } from './Home';

3Verify

Restart the dev server and open the page. The error is gone.

npm run dev

Confirmed by developer.mozilla.org

Did this fix it?

Cause 2 of 3

The component has no export keyword at all

1Check

A function that is only declared in a file is private to that module. Without export, importers cannot see it.

grep -n "function Home\|const Home" src/Home.jsx

2Fix

Add an export in front of the declaration, or an export statement at the end of the file.

export default function Home() {
  return <h1>Home</h1>;
}
// or, at the end of the file
// export { Home };

3Verify

The import resolves and the component renders.

grep -n "export" src/Home.jsx

Confirmed by developer.mozilla.org

Did this fix it?

Cause 3 of 3

The imported name differs from the exported name

1Check

Named exports must be referred to by the exact same name when imported. You may rename one with as. List the names the file really exports.

grep -n "export" src/Home.jsx

2Fix

Use the exact exported name, or rename during import with as.

// Home.jsx has: export function HomePage() {}
import { HomePage } from './Home';
// or rename locally
import { HomePage as Home } from './Home';

3Verify

Save the file. The editor shows no import error and the page renders.

npm run build

Confirmed by developer.mozilla.org

Did this fix it?

How do I stop it coming back?

  • Choose one convention for components, for example one default export per component file, and keep to it.
  • Let the editor write imports through auto-import, so the braces come out right.
  • Do not put two export default statements in one file: it is a SyntaxError.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.