Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NextJS Module not found: Can't resolve 'components/layout' #557

Open
oskar-gmerek opened this issue Sep 3, 2020 · 0 comments
Open

NextJS Module not found: Can't resolve 'components/layout' #557

oskar-gmerek opened this issue Sep 3, 2020 · 0 comments

Comments

@oskar-gmerek
Copy link

oskar-gmerek commented Sep 3, 2020

Hello. I was want to try gts in my project. After 'npx gts init' when I try to start my project I getting an error:

error - ./pages/_app.tsx:6:0
Module not found: Can't resolve 'components/layout'
import Layout from "components/layout";

Before gts everything was good. Anyone have any ideas?

Edit

App structure in my case:

App
- components
-- layout
--- container.tsx
--- index.tsx 
- lib
-- [...]
- node_modules
-- [...]
- pages
-- _app.tsx
-- error.tsx
-- index.tsx
- public
-- [...]

Error:

error - ./pages/_app.tsx:6:0
Module not found: Can't resolve 'components/layout'
import Layout from "components/layout";

Line 6 of _app.tsx:

import Layout from "components/layout";

File components/layout/index.tsx contains:

[...]
const Layout: FC = ({ children }) => {
  return (
    <ColorModeProvider>
      <LightMode>
        <Navbar />
        <Container>{children}</Container>
      </LightMode>
    </ColorModeProvider>
  );
};

export default Layout;
[...]

Adding baseUrl to tsconfig.json fix that problem:

"compilerOptions": {
    "baseUrl": ".",
}
This was referenced Sep 4, 2020
@bcoe bcoe added the type: docs label Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants