The bottom line is, we need our Docker container to be reachable by an external debugger. Its very similar to the tutorial involving Docker Compose but without the nginx reverse proxy. To easily get up and running, you can use this Github repository to get up and running. If you’re coming directly to this tutorial on debugging docker containers, I’ll be assuming you’re familiar with Docker Compose.Īs a bonus, we’re also going to look at nodemon for monitoring server side changes and restarting our server without us having to shutdown and restart containers on ever server-side change. If you haven’t started, but are interested in hosting your applications development environment inside Docker containers, you’re going to want to check out the recently released Docker for Devs tutorial. In this first part were going to look at how to use WebStorm, followed by Visual Studio Code and finally hooking up the good Ol’ fashion node.js debugger. This is the first of a three part series where were going to look at how to debug docker containers running an React.js/Node.js/Express.js application. Have a look at the previous post on Node.js development in our blog: “Getting started with Node.js in WebStorm”.If you’re using Docker to host your applications development environment, it will be important to know how to debug your applications source code running in the container. Please note that for remote debug your app should be running with -debug= or -debug-brk= parameter. You’ll be able to use full-featured debugger in the same way as if you were debugging your code locally. You’ll see the Debug tool window when the breakpoint is reached. Now that the debug configuration is ready, select it from the drop-down list of configurations on the right and click Debug. Select Remote Node.js Debug type when creating a new debug configuration, then specify the host you need to connect to and the port. You’ll be able to restart the debug session without restarting the app itself. With Remote Node.js Debug configuration you can debug Node.js apps that are running remotely. A tool window with variables view, frames and watchers for your debug session will appear: ( Shift+F9 on Windows or Linux, Ctrl+D on Mac). The built-in Node.js debugger allows you to step through the breakpoints, change values on the fly, evaluate expressions, and set watches.Ĭlick the Debug button for the created Run/Debug configuration in the top right-hand corner of the IDE, from the Run menu or with the shortcut The same configuration can be used to debug your Node.js code. The Run tool window with console will appear showing the app execution log. Update: Starting with Express 4.0 file Select this new configuration and click Run. You can also add any parameters you need to pass to node ( Node parameters input) or to your application ( Application parameters input) on the start. For example, for a simple Express web app it should be a file that configures and starts the web server. In this new Run/Debug configuration, specify the path to the JavaScript file that needs to be executed. To create a new Run/Debug configuration, click Edit configurations in the top right corner of the IDE window, or in the main menu Run.Ĭlick Add new configuration and seleсt Node.js type. WebStorm allows you to run Node.js application locally on your machine: you should create a Node.js Run/Debug configuration for the file you need to execute and click Run. Our first post covered the basic WebStorm configuration for working with Node.js projects. Now let’s move on to running and debugging Node.js apps both locally and remotely. Let’s continue our series of posts and tutorials on Node.js development in WebStorm. Check out a newer blog post on debugging Node.js apps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |