Next.js Discord

Discord Forum

importing index.ts from root directory doesnt working directly

in my project i have this folder structure

and im trying to import components from index.ts
@/components import should work but is doesnt seem to work and that why next throughs the error module not found

But if tyed to use import {foo} from "@components/index it works why is that as mentioning root directory index.ts export should recognized default

5 Replies

European sprat
Show your tsconfig
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}
\