A React component import fails because the file has no export with that name
Home does not contain an export named HomeShort 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.
Fix it fast
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/2Match what you see, then jump to its fix
- 1
The 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
grep finds no export line for the component in the fileThe component has no export keyword at allFix - 3
The file exports a named value, but under another spelling or caseThe imported name differs from the exported nameFix
- 1
What does the error look like?
Home does not contain an export named Homeimport { 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 devConfirmed by developer.mozilla.org
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.jsx2Fix
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.jsxConfirmed by developer.mozilla.org
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.jsx2Fix
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 buildConfirmed by developer.mozilla.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix