Debugging Beyond Code: How I Conquered the Live-Server Installation Process

Debugging Beyond Code: How I Conquered the Live-Server Installation Process

ยท

5 min read

Overview

I've recently started exploring the field of Web Development and with no doubts, I'm enjoying the process. Now I can say that I've gotten the basics of HTML, CSS and JavaScript, as these are the building blocks of the web. Now back to the topic after I got the basics, I decided to take one step further by switching the live-server from GUI to the command line. The reason behind this is quite simple as a developer, you should be spending most of your time working with the command line rather than the GUI. The twist is it was not an easy process for me. I ran into lots of errors in the whole process of installing and running live-server. I'd spent almost my whole day fixing this and I can proudly say it is one of my best debugging experiences.


What is live-sever?

For folks who are not familiar with live-server, here's a quick overview for them. So, they all can get the most out of this article.

Live-server: Live-server is a tool that enables developers to quickly and easily serve web pages from their local machine for testing and development purposes. There are two main ways to use live-server: as a standalone package installed globally using npm, or as an extension for popular code editors like Visual Studio Code.

Now, let's get started and debug this...


Installing Node.js and Chocolatey

The first step to using live-server from the command line was to install node.js on my machine. The very first problem I faced was while installing node.js. As node installation is pretty simple but I got confused with this additional install. I had not even heard about it before. After some hours of research, I understand nothing except that it's a package manager ๐Ÿ˜…. I still didn't find my answer should I install Chocolatey or not? So, in fear of not lacking anything. I had decided to install these additional packages and this was my very first mistake. I don't recommend anyone of you to install any software about which you don't know anything.

Node.js was installed without any issues. But just after the node.js was installed, a PowerShell window opened on its own and it started installing Chocolatey and some other additional tools. It took more than an hour to install Chocolatey and all the other packages.


Python Version Conflicts

After this, I found that the latest version of python 3.11 automatically got installed with Chocolatey on its own. But I already had python 3.10 installed on my system. So, I decided to go ahead with the latest python 3.11 and I uninstalled the previous python version from my system which I was using before. After uninstalling the previous python version, I found that pip was not working with the new python version in my system. Tried a lot of things to fix this but nothing worked for me. At last, I decided to uninstall the python version that came with Chocolatey and installed the latest python 3.11 manually. After this, the python thing got sorted.


Installing Live-server

Now it was time to move ahead with the main reason for all this, live-server installation. By running node -v, I confirmed that node.js was running fine on my laptop. The next step was to install the live-server. I installed the live-server by running the following command: npm install -g live-server

It got installed without any issue but after this when I ran the live-server using live-server command in my terminal, it ends up with an error which is saying that the running scripts are disabled on my system. If anyone of you using windows like me you'll get the same error it's all because of some Windows policies which I got to know about the next day after some googling.

Till this point, I started getting more and more frustrated. I had been working on this for hours, and I still had no idea why it was breaking at the last moment. As it got midnight already I decided to take some rest and got my head around it tomorrow**.**


Final Debug

After getting some sleep, my mind got refreshed. And I started to sort things again from where I left off yesterday. After spending some time on Google and Stack Overflow, I got my answer. Live-server was not running because of some PowerShell security policies. To fix this, I ran Powershell as administrator and ran the following command: Set-ExecutionPolicy RemoteSigned

Finally, you know what? It worked ๐Ÿ˜Ž


Wrap-Up

Overall, by installing and running live-server from the terminal, I have demonstrated my ability to troubleshoot problems and debug complex issues, which is an important part of the development process.

For people who argue that installing and running things is not debugging. For them, I want to say that debugging is not only about fixing errors in code but also about solving issues and troubleshooting problems that may arise during the development process. Installing and running live-server from the terminal is a perfect example of such a challenge.

If you enjoyed this article and want to be a part of this amazing journey, don't forget to follow me on Twitter for more content like this!

"The best way to predict the future is to debug it." - Alan Kay

ย