How to get your app running when it just won't start
Tags: codenewbie, javascript, beginners, internship
Published: 2021-06-18 03:08:26

Probably the most frustrating thing as a software developer is when you're excited to make an important change, eager to code something really neat, but your local dev environment absolutely refuses to get into gear. This has happened to me a few times now at my new internship, and as a result I've picked up a handful of new ways to try and kick some life into an app that just fails to start. So, I thought I'd share them with you all!

#### 1: Turn it off and on again!

![Man looking at computer in front of fire](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wdtb8e37vz4tv4rbeim.gif)
*I know it's simple, but it could save you a LOT of time! [GIPHY](https://giphy.com/)*

Okay, I'll admit it, you probably tried this already. _However_, if you haven't, it could be worth a shot.

Plus, some dev environments — especially at larger companies — take full advantage of advances like hot reloading and live code injection. These are only a few, but there's a whole host of packages and dependencies whose sole goal is to remove any friction between you and writing your code (including recompiling, reloading, re-_anything_).

With features like these, who needs to restart apps nowadays? Clearly, you do. So go ahead and give it the old IT crowd restart. It probably won't hurt, and it might even help.

If it doesn't, though, you could try to...

#### 2: Get rid of your compiled folder

This was a neat little trick that has helped me a lot recently. Sometimes, the folder where all the magic compilation happens (think `dist/` for `npm`) can get corrupted. If that's the case, a simple restart won't do much to help. Times like these call for a little more _incisive_ action! Removing the folder with all the compiled files can help clear out any of that corruption, and your app should recompile everything when you start it up again. There's not much a good old `rake assets:clean` or a `rm -rf dist/` can't fix!

#### 3: Reset your dev database

Sometimes, the issue isn't with the app at all. It's very possible that the dev database is causing some underlying issue, so that no matter how many times you restart your app or delete the compiled files, it still won't work. This can be very frustrating, since database errors can happen without any warning. Often you'll see logs pointing you in the general direction of a fix, but these logs can be cryptic and confusing, especially if you're not too familiar with the app. Maybe it got corrupted, or maybe some database operation ran when it shouldn't have. In either case, nuking the whole thing is a reliable (if overkill) way to resolve the issue.

If you've got a decent dev environment set up, it should be as easy as running a few `make` commands. If not, though, you might be in for a world of hurt. Don't forget to brush up on your `SQL` before diving in!

#### 4: Pull in the latest commits

You might not be the only one experiencing the issue. Maybe some more experienced engineers caught wind of it, and even fixed it for you! However, you'll never know unless you pull their latest changes in. This might not be super effective in a company that uses microservices, since most of the code is encapsulated in different repos, but for companies that use a monorepo, this could be a game changer. Moving parts are always prone to breaking, and sometimes another team pushes something that maybe should've gone through another review. Sure, they might have fixed it 5 minutes afterwards, but you'll never know unless you pull those most recent commits in.

Bonus: If you've been working on something in a separate branch, you've got (essentially) two options — `rebase`, or `merge`. While both have their pros and cons, I'm generally a fan of rebasing. But keep an eye out for a post further down the line where I go into more detail looking at the differences between the two!

#### 5: Delete your dependencies and reinstall them

If the problem isn't with your app, isn't with your database, and isn't even with your repo, it might be somewhere else entirely! Apps nowadays rely on a vast network of dependencies, almost to a ridiculous extent (I'm looking at you, [is-odd](https://www.npmjs.com/package/is-odd)). It's like a very fragile house of cards where one false commit can cause the whole thing to throw errors like candy at a parade. (Do they throw candy at parades? Weird analogy.) In any case, one of your dependencies could have gotten corrupted. The easiest fix? Delete that `node_modules` folder! Delete those `gems`! Run that `npm install` or `bundle install`! Revel in your newfound lack of errors!

Note: there's a not insignificant chance that doing the above may cause the entire thing to implode even more, so please do it with caution. Some maniacal glee, sure, but mostly caution. Dependencies can be **sensitive**.

So there you have it! My not at all exhaustive list of ways to possibly rejuvenate your app (or make things worse). I hope my experiences have helped you, even a little, and be sure to stop by regularly for even more interesting posts. If you found this one useful, consider [buying me a coffee](https://shaile.sh/coffee). Until next time!