how to avoid not module found error in AWS ec2 when hosting an application

ยท

1 min read

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... ๐Ÿš€

ย