Next.js Discord

Discord Forum

Alias @ broken

Answered
Goldstripe sardinella posted this in #help-forum
Open in Discord
Goldstripe sardinellaOP
Hi, I'm new to NextJS. I've been playing with since a few days and this is the first time my alias "@" does not work as espected as you can see on the screenshot. My jsconfig.json :

{
"compilerOptions": {
"paths": {
"@/": ["./src/"]
}
}
}

import NavBar from '../../components/header/navbar/NavBar';
works fine but not
import NavBar from '@/components/header/navbar/NavBar';

I already tried to del the folder .next and rerun the server.
Answered by joulev
Your tsconfig.json is clashing with jsconfig.json. Remove jsconfig.json and add the paths array in that file to tsconfig.json
View full answer

4 Replies

Goldstripe sardinellaOP
Answer
Goldstripe sardinellaOP
Oh thank you it's all good !
At some point I created a .tsx component unstead of a .jsx component. Did NextJS automatically created the tsconfig.json because it detected a ts component ?
@Goldstripe sardinella Oh thank you it's all good ! At some point I created a .tsx component unstead of a .jsx component. Did NextJS automatically created the tsconfig.json because it detected a ts component ?
Yeah nextjs creates it when it detects you use typescript. In this case you use middleware.ts which necessitates tsconfig.json