This content originally appeared on DEV Community and was authored by Lucas Schiavini
So hello, it’s been a while, and I haven’t being keeping up with my daily dispatches, or maybe my days are longer than yours. Relativity man, who knows?
So I was playing around with a Node.js project hosting it using Docker alongside a Postgres database.
And I was all happy and dandy until I wanted to debug an error.
And I couldn’t.
So I went far and wide, talked with many friends (I wish), and came across this cool article Debugging uncompiled Typescript code running on a Docker container | by Mitsuhide Ohi | Medium.
This article pointed me towards the right direction, but I had to add a few things.
1 — First of all, I didn’t need to add a debug script to my package.json. I merely replaced my --inspect flag with itself + server_address:port --inspect=0.0.0.0:9229.
2 - I did add the next line on my tsconfig.json.
"sourceMap": true
3 — Here’s where things differ a lot from the article, my debug configuration didn’t use the sourceMapPathOverrides (it did nothing for me). Instead I replaced it with these two cool properties ( remoteRoot and localRoot):
4 — Now to the docker-compose.yml file, I added to my mainApp service the docker port for debugging
5 — After all that, I had to run docker-compose up -d --build --force-recreate since I changed the docker-compose.yml file.
And then BOOM! It worked.
Liked my content? Feel free to Buy me a Coffee ☕.
Didn’t like my content? Share your thoughts in the comments!
Lucas Schiavini
All my content | LinkedIn
Originally published at https://skiraindustries.com on June 1, 2022.
This content originally appeared on DEV Community and was authored by Lucas Schiavini
Lucas Schiavini | Sciencx (2022-06-01T20:31:58+00:00) Debugging NodeJS within a Docker Container. Retrieved from https://www.scien.cx/2022/06/01/debugging-nodejs-within-a-docker-container/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.