April 15, 2020

Today was quite the journey through Express. I loaded up Express into an existing project and thought I’d be able to simply add a line of code to serve up some files in a directory. I soon came to realize that a complete refactor of the code would be necessary, however. After a bit of reading, I came across the capability of creating a skeleton project and decided to scrap what I already had and give this template scaffold a try.

Little did I know a wild goose chase would ensue. Upon scrapping the old code, setting up a new project, and initializing a new git repository, I was no longer able to serve up any webpages. At first, I thought this was an issue with nginx, as I had stipulated an index.js file to handle the server nonsense and perhaps needed to change that to the new app.js variant. However, this was not the case, as I had configured nginx to operate as a reverse proxy, so being specific with the controlling file wasn’t necessary.

Next, I tried running the app directly through Node, calling “node app.js.” But this did not work. So I began digging around to figure out what I could discover regard running an Express-based app. Mozilla to the rescue. I came across this article that introduced me to the “npm” command. I was able to start the app and serve up my site with no 502 error. And this page helped me get it set up with pm2, so now my app remains running. This is all super exciting.

Comments? Follow me on twitter and drop me a line in response to this tweet:

Day 003: after tumbling down two different rabbit holes, I finally figured out how to serve up some content on my site. This link, and the two prior, are now clickable and will serve up some boring-looking pages: https://t.co/mUwtg6MDvw#nonsensemod365 #thatCodingLife pic.twitter.com/GDYltS13f7

— Joshua Alexander (@nonsensecodes) April 16, 2020