Next.js Discord

Discord Forum

Suddenly getting module not found error.

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Hello, im getting this module not found error out of nowhere, it was working fine but then my dev server lost connection which happens sometime for some reason, after i restarted it by npm run dev, i started getting this error.
Tried fixing it for 4 hours and failed!

Things i have tried-

1. Restarting the server multiple times.
2. deleting the next dir, again multiple times
3. closing and reopening my IDE and starting the dev server again.

After that i gave up and took a break for 2 hours and it was working fine when i came back.....
and 12 hrs after that again same issue the dev server lost connection which happens sometimes and i started getting this error again.
Answered by riský
can you try moving the style into the same folder as component/page and using relative import (./file.module.css)
View full answer

2 Replies

can you try moving the style into the same folder as component/page and using relative import (./file.module.css)
Answer
West African LionOP
relative import did solve it, but i tend avoid relative imports.
anyways its fixed now, i had to edit my tsconfig.json file and specify the paths there as well, which is weird bcs i didn't initialize the project with typescript as it was my first nextjs app.
Thanks!