Anyone know why I'm getting this error?
When I run npm run dev, I get a module not found error. It was working fine just yesterday, but today it suddenly stopped.
I deleted node_modules and reinstalled, but it's still the same. If anyone knows, please help ㅠ
6 answers
Nobody can tell you without the full error log lol — the key part is what xxx actually is in Cannot find module 'xxx'
Start by checking node -v. If you're using nvm, the version changes every time you open a new terminal, so it often ends up different from yesterday.
I ran into the exact same thing, and it turned out to be an import path case-sensitivity issue lol. It worked fine on Windows, but as soon as I put it on Linux/Docker, I suddenly got module not found. If it’s capitalized like Components/Button, scan through and make sure it exactly matches the filename.
But isn't it the most suspicious thing that something that worked fine until yesterday doesn't work today? lol Usually it's one of three things: you installed something, checked out a branch, or changed your Node version. Think about that first.
Also delete package-lock.json and try reinstalling.
It could also be a cache issue. Try running npm cache clean --force, delete node_modules and package-lock.json, and run npm install again. If that still doesn't work, check whether the file referenced in the dev script actually exists. It's also worth checking whether the import statement is missing a file extension.