how to avoid not module found error in AWS ec2 when hosting an application
Hello everyone! ๐ก
Ever been stuck solving a problem for hours?
Let me share my story: Decided to host my application on Amazon EC2, installed all the necessary packages, and cloned my project from Git.
Upon hitting 'npm start,' I encountered a 'module not found' error. It ran smoothly on my local machine but not on the virtual one. So, I started figuring out, what may be the issue, and eventually, I discovered the solution: I needed to change all my models file names from uppercase to lowercase(it's case sensitive on Linux server) . Seemed easy enough, right? ๐ต๏ธโโ๏ธ
After renaming all the model files, I pushed the changes to Git and tried 'npm start' again. To my dismay, the same error persisted. I started debugging again
Then, I realized that the changes I made locally weren't reflected on GitHub repo. Git didn't recognize the minor file name changes (e.g., UserModel => userModel).๐ซ
So, I manually adjusted all the file names in my repository, and finally, the the error is debugged and my application is successfully hosted. ๐
The moral? Not everything can be learned from the internet. Some lessons come only from experience... ๐