![]() ![]() Either of these IDEs though provide me with the ability to now dig deeper into Node.js itself whilst examining exactly what's going on in the code which is the objective I really started with. It's possible that I've missed something around that in configuration (again, as a beginner), but I was able to achieve what I wanted with both. I found that Webstorm was relatively quick to set up and get to the point of debugging, but I found a slight annoyance that I had to keep restarting the debugger after a file edit, which I didn't have to do with VS Code. ![]() It seemed to me (from my beginner's perspective) that setting things up in VS Code was a lot more complicated than Webstorm, but the result was slightly better. ![]() I will say though that both IDEs make it possible for the management of Docker containers and the step debugging. I'll not repeat everything here that I've put in my Github repo's README.md file, as that file describes exactly what's need to be done for both VS Code and Webstorm to enable you to be able to run and step debug the Node.js app whilst running in a Docker container. Now there's the application, a Docker image that can be used to create a Docker container to run the app within it, the last thing left to do is integrate all of these with the IDE(s). or docker-compose up -d you can visit in the browser and view the Node.js app running in a Docker container. To remove the need to use quite a long command to create/run the Docker container, I created a docker-compose.yml file that enables all the command line options to be defined within a file under a 'service' definition (compose files are ideally for when you have many separate services to use, but that's a bit of a tangent in this context), so we can then just use docker-compose up -d instead of a long-winded docker run. The run command also mounts the current directory as a Docker volume to share the application code with the container as well as mapping the local port 3000 to the exposed container port. ) and how the container is then run with a docker run -d -p 3000:3000 -v (pwd):/app alexsansom/nodejs_docker command. The comments in that file describe how to build the image ( docker build -t alexsansom/nodejs_docker. As you can see from the linked file, 'the specifics' were basically to install 'nodemon' (so that edits to the app are able to be reflected immediately in the browser), globally, in the container. The first step for this is to create a Dockerfile that uses the official Node Docker image for it's base, and then to add any specifics around that. Next up then is building a Docker image to be used as a template to create a container from that will run my simple app with Node.js. That's the app running locally on my machine, but my aim was to have this running in a Docker container, before getting to the point of being able to single step debug it using an IDE. Running the app, you then visit localhost:3000 in the browser to see its output. The simple application I chose was to serve a web page with a small variation on 'hello world', which also output's the time in milliseconds, so you can see that the page content is changing on each page refresh. A quick npm install after having installed node itself and you're ready to create an application. You see it used in a lot of examples around the web, and I've also had it previously recommended to me by a friend who's a full time Javascript developer. Looking around, it seems that the go-to web framework for Node.js is a package called ' express'. The general plan was to get a simple Node.js application running, which I could then build a Docker image for so that the app could run in a container, and then to see how the two different IDEs enabled the ability to be able to debug it. I've had a bit of time recently to finally start trying to dig into a few things, so I thought I'd (possibly unwisely exposing myself to potential information overload) combine a number of these things into a single small activity. ![]() A number of things I've had down on my 'todo' list to look at for a while are: VS Code (having seen in mentioned a fair amount whilst generally reading around), Node.js (have been meaning to take a look for ages, and it's supposed to work well with VS Code), Docker (I've been using it in recent projects but want to understand it better) and, Webstorm (as a possible alternative to VS Code for Node.js, as well as being part of the same family of IDE's as PHPStorm which I use frequently). ![]()
0 Comments
Leave a Reply. |