Debugging through the whole Hackathon
6 min read
You might find it funny but I was pissed up when I had to debug for absolutely four hours during the hackathon.
Some say debugging is fun, some say it isn't but I say it depends on the situation you are on. Let me share my story of debugging with you guys.
How it all started?
So, to attend an offline Hackathon, my friends formed a team and named it Debugging army. It was our first Hackathon and we were excited about it, it didn't matter what the name is. The name was chosen by my teammate Rajesh Khadka and during the hackathon, we had regret the name. The reason might seem a bit silly but 2 hours into the hackathon, here we are with the name Debugging Army and got the bug. Actually, the bug arose on my PC, and that too after executing the git pull command.
The error was saying something on the red text but when I checked it, there was not anything bad as the error mentioned. Yep, that is the worst thing that can happen when you are debugging. And within a couple of hours of getting started on the hackathon, I was struck by a stupid error.
The error was there due to the expo as we were making a mobile application using React Native. Believe me or not, when a web developer tries to make a mobile application he really cries for hours. Yes, I faced it 🐱 Anyways here is the screenshot of the error.
I was getting this error every time I was trying to start my expo app. Yep that shitty
expo start command didn't work.
It is said that a developer spends his maximum time debugging and I realized that things were very well after a couple of hours of getting started in the hackathon.
Why not if I share with you that are the really stupid things I did during the hackathon to resolve this error? First of all, as mentioned in the error, I tried finding the JSON file to resolve the error. So after many unsuccessful attempts, I tried other approaches which I am going to lay down as follows.
Deleting the files
Alright, the very first thing I did was deleted the node_modules folder and reinstalled the packages. Since the error looked like this:
Starting project at C:\Users\Admire\OneDrive\Documents\Projects\project-dharan\app JsonFileError: Error parsing JSON: └─ Cause: SyntaxError: Unexpected token in JSON at position 0 1 | | ^ JsonFileError: Error parsing JSON: └─ Cause: SyntaxError: Unexpected token in JSON at position 0 1 | | ^ at parseJsonString (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules@expo\json-file\build\JsonFile.js:160:19) at Function.readAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules@expo\json-file\build\JsonFile.js:139:12) at async getPackageVersionAsync
I thought the error is due to the
package.json file so I deleted my project completely from my PC. And then cloned the project from GitHub. I reinstalled all of the dependencies. And all I had to see was the same error. So I tried deleting the project multiple times but it didn't work. Later on, I decided to clone the repository in a separate location and still slammed up by the same error just straight on my face.
Deleting the expo globally
Yep, I really thought that error might be there because the expo-cli freaked out unnecessarily. So I deleted the expo-cli globally and reinstalled then again ran the very important at the same time the most depressing command and that command is: yes, you guessed it
My bad luck was with me this time also. So I decided to get bigger. So now
Deleting the Nodejs
Nothing was working. That's the reason why I uninstalled the node js completely from my PC then installed the latest LTS version which was 18.x then I tried cloning the project again and reinstalling the packages again.
Then I asked my friends which version they were using. They were actually using 16.x so the version wasn't the problem so I reverted back to nodejs 16.x and continued with other ways to resolve the error.
Getting help from others
Look I was frustrated and tired. Now it was the time to go out, grab some coffee and chill out. Just in that time, my friend hopped in to help me out. So I stayed there looking at the ways he is trying to fix the problem. Ok the bug won, he was also unsuccessful to figure out what the error was and what the heck was the source of the error.
It's time to get some help from mentors. There were many mentors out there in hackathons to help anyone out in case they get into any error. So we called for one. We had to wait just a minute and the mentor arrived but with no luck. Well, he was getting late for his home as it was almost midnight so I still had the bug but the mentor left.
Changing the platform
At this time, I was pretty sure that the error I am getting is because of my PC. It wasn't the problem with my teammate's computer. So, I tried to change the environment of my project development.
In short, I download the ubuntu 20.04 LTS ISO and fired it up with Oracle Virtual Box. I set up nodejs and installed the android studio as I was using an android emulator for testing out my mobile application.
In the meantime, I got another mentor so I handed over my laptop to try his luck. He wasn't confident if he can solve the bug or not. Surely there can't be any expectations to solve any error if you haven't used react-native in past. Still, he tried. The first thing he did was used npm to manage the dependencies of the project. I was using yarn as I had faced really bad problems with npm in past.
He started shooting up different commands to start the project. He even helped me to set up the android device manager for the android emulator on Linux.
Just when we completed setting up the Linux development environment, he fired up the
npm start command on the project again. Strangely, this time it worked. No, I am not kidding, seriously it worked. My project started and after many hours of struggle, I was finally able to view the app on my phone.
It is still super mysterious and I am still trying to understand why I got the error and what file actually was causing the error. One of the really interesting things I forgot to share here is that my friend asked for the solution to this error on StackOverflow for over 100 bounties.
You can still find the question on StackOverflow. But seriously I am still amazed at how the hell my project started.
I got to learn a lot of things due to this bug. But everything is not there to learn and you cannot take everything as a good thing. It depends upon the situation. This time I was really stuck for 4 hours during the 24-hour hackathon due to a silly bug that was just mysterious.
In conclusion, the process of debugging can be both challenging and rewarding. While it requires dedication, hard work, and a lot of critical things, the happiness you get after solving the error is on the next level.
Why not end the blog with a good memory? A photo from the hackathon:
Let's connect on Twitter. My DMs are always open.