Home does not contain an export named Home

This is a case where you mixed up default exports and named exports.

When dealing with the named exports, if you try to import them you should use curly braces as below,

import { Home } from './layouts/Home'; // if the Home is a named export

In your case the Home was exported as a default one. This is the one that will get imported from the module, when you don’t specify a certain name of a certain piece of code. When you import, and omit the curly braces, it will look for the default export in the module you’re importing from. So your import should be,

import Home from './layouts/Home'; // if the Home is a default export

Some references to look :

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
  • https://medium.com/@trekinbami/a-not-so-in-depth-explanation-of-es6-modules-import-and-export-13a80300f2f0

I just ran into this error message (after upgrading to nextjs 9 some transpiled imports started giving this error). I managed to fix them using syntax like this:

import * as Home from './layouts/Home';

Use

import Home from './layouts/Home'

rather than

import { Home } from './layouts/Home'

Remove {} from Home


The error is telling you that you are importing incorrectly. Here's the code you have to add:

import { Home } from './layouts/Home';

This is incorrect because you're exporting as the default export, not as a named export. Check this line:

export default Home;

You're exporting as default, not as a name. Thus, import Home like this:

import Home from './layouts/Home';

Notice there are no curly brackets. Further reading on import and export.