NextJS '@' Path Seems To Be Off?
Answered
West African Lion posted this in #help-forum
West African LionOP
I'm getting the following error:
I tried going into the
The following does seem to work, but I don't know why the original didn't as this is something I've used in many other projects
Cannot find module '@/components/SettingsMenu/SettingsMenu' or its corresponding type declarations.I tried going into the
tsconfig.json to remap the path but it is still throwing a compilation error"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/app/*": ["app/*"]
}
},The following does seem to work, but I don't know why the original didn't as this is something I've used in many other projects
import SettingsMenu from "../SettingsMenu/SettingsMenu";Answered by joulev
You are declaring the absolute path import starting with
@/app, so all your imports of this kind must start with @/app so @/components for example is invalid26 Replies
@joulev Looks like it should be "src/app/\*" instead of "app/*"
West African LionOP
I tried the following, but no luck 😦
"paths": {
"@/src/app/*": ["app/*"]
}
"paths": {
"@/src/app/*": ["src/app/*"]
}
"paths": {
"@/app/*": ["src/app/*"]
}@joulev Can you send me the repo link?
West African LionOP
Sure, one sec! Let me commit this stuff rq. I'm not sure if this is related but I'm also having issues with @apply in the
global.css@joulev Can you send me the repo link?
West African LionOP
I didn't even start yet. Just
create-next-app and removed some of the template code from page.tsx@West African Lion https://github.com/EladKarni/acc-ipad-app
You are declaring the absolute path import starting with
@/app, so all your imports of this kind must start with @/app so @/components for example is invalidAnswer
Change
@/app/* to @/*West African LionOP
Yep, that was it! I'm an idiot sorry!
@West African Lion Sure, one sec! Let me commit this stuff rq. I'm not sure if this is related but I'm also having issues with @apply in the `global.css`
This should be unrelated, please make a new post with a reproduction repo like the above
The repo link helped a lot in debugging
West African LionOP
I'm not sure what you mean I'm sorry
Happy to help, just unsure what you mean by this?
As in, if you didn’t send me the link to your repo then I could not find the bug for you
By sending the repo link you made it a lot easier to help you
West African LionOP
So post a clone repo that I won't update so people can see?
You seem to not understand what I said so… ignore me
West African LionOP
I'm sorry 😭
Either way make a new post for your
@apply questionWest African LionOP
Ohhh
New post
I get it
Yeah that just came up and I wasn't sure if that was related, so I wanted to give more info
It wasn't so I'll try debugging that myself before posting
Thank you again so so much
You are welcome, have fun coding and have a good day