importing index.ts from root directory doesnt working directly
Unanswered
▄︻デZ̷o̷r̷o̷ ̷O̷P̷╅ posted this in #help-forum
in my project i have this folder structure
and im trying to import components from index.ts
But if tyed to use
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 default5 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"]
}\and if you ask me about
"moduleResolution": "bundler" then https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#moduleresolution-bundler@▄︻デZÌ·oÌ·rÌ·oÌ· Ì·OÌ·PÌ·â•â•â”一 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
shouldnt it be @/components/index or just @/components
Also, please be patient