Next.js Discord

Discord Forum

Path Problem

Answered
Dutch posted this in #help-forum
Open in Discord
DutchOP
i get this error when i use @
but i use .. it works
i tried fixing the json file
still its misbehaving
why?
Answered by Southern rough shrimp
in your tsconfig.json, inside compilerOptions, add this:

    "paths": {
      "@/*": ["./*"]
    }
View full answer

44 Replies

@Dutch i get this error when i use @ but i use .. it works i tried fixing the json file still its misbehaving why?
Southern rough shrimp
what does your tsconfig.json look like
And also send a screenshot of your folder structure
DutchOP
Southern rough shrimp
You need to set up the @ alias. It's not something that exists without configuration
Southern rough shrimp
in your tsconfig.json, inside compilerOptions, add this:

    "paths": {
      "@/*": ["./*"]
    }
Answer
DutchOP
i did it while installing the app
and it game me error now
while it was working fine since 3 days
Southern rough shrimp
Well you need that alias set up in tsconfig either way, it wont work otherwise.
DutchOP
i alreadyy have this in my jsconfig.json file
@Southern rough shrimp Well you need that alias set up in tsconfig either way, it wont work otherwise.
DutchOP
but i already had it and it still throws me this error while using @
@Dutch Click to see attachment
Southern rough shrimp
Where is this code? it's not in your initial screenshot
DutchOP
that one was tsconfig
this is jsconfig
Southern rough shrimp
You either use tsconfig or jsconfig. having both is bad
My opinion would be to move that into your tsconfig, and then delete jsconfig
DutchOP
lemme try and see wwhat happens
Southern rough shrimp
Do you plan on having any typescript in your code
DutchOP
not now
Southern rough shrimp
Ok then instead of deleting jsconfig, move everything into jsconfig
Then delete tsconfig
DutchOP
i think so adding it to tsconfig was needed idk why it was working with @ before
since last 3 ddays
bruh
Southern rough shrimp
what file are you importing it from
DutchOP
jsx
Southern rough shrimp
does it work now?
DutchOP
yeh it does but i dont understand wwhy it wwas working before
i had to use relative path
and now that i updated tsconfig its working with @
Southern rough shrimp
Tbh i suggest using typescript for any of your programming
But thats just my opinion
make sure to mark the solution by right clicking the message that fixed it and going to 'Apps > Mark Solution'
DutchOP
u saying maybe cus it was jsx it wwas throwwing the issue?
Southern rough shrimp
nah
typescript is just better
DutchOP
shit works works fk it
Southern rough shrimp
amen brother
DutchOP
peace
Southern rough shrimp
make sure to mark the solution
DutchOP
how do i do that
Southern rough shrimp
by right clicking the message that fixed it and going to 'Apps > Mark Solution'
DutchOP
oh ok