electroniclooki.blogg.se

Webstorm node js debug
Webstorm node js debug













webstorm node js debug
  1. #Webstorm node js debug how to#
  2. #Webstorm node js debug full#
  3. #Webstorm node js debug code#

You should now see the following window, The template window with defaults selected Select the Attach to Node.js/Chrome option, Base the template off the Node.js attachment template option on the top right, Add debug configuration in WebstormĬlick on the + symbol above templates so that we can create our own custom template. In Webstorm, click on the Add Configuration.

webstorm node js debug

This is the port that I need to set the IDE debugger to listen on. Configuring your IDEĪs mentioned previously, I am binding port 9229 in the docker container to port 30000 on my local machine. So the next step is to set up our IDE (in my case, Webstorm) to utilise this setup.

#Webstorm node js debug code#

That's all we need in our project to allow for our debugger to intercept and stop the code at breakpoints we set. Meaning that our nodemon.json file now looks as follows, The command for execution should change from the above command to the following, node -inspect=0.0.0.0 -require ts-node/register -require tsconfig-paths/register src/main.ts.

#Webstorm node js debug full#

If you haven't heard of inspect before, take a look at the official documentation for full details. We're going to use the -inspect option in node to allow us to access the debugging information. We need to change this to start with node and then we can add some debugging flags. In the nodemon.json file, the command for execution is currently ts-node -r tsconfig-paths/register src/main.ts. Instead of using ts-node directly (which is what we do for a lot of Typescript projects), we should rather start up node normally and register the ts-node module. The next step is to configure our package.json and nodemon.json files to allow for debugging. You'll notice that I bind port 9229 in my docker-compose.yaml file, this will be very applicable in the next steps so don't forget it! For future comparison, this is what the package.json and nodemon.json files look like in the backend folder before I set up the debugger, Enabling the Debugger in a Typescript ProjectĬool so we're set up with the docker-compose.yaml and Dockerfile and if you run docker-compose up -build you should see the system build and start up. So currently, my docker-compose.yaml and Dockerfile look as follows, You'll also see a devops folder where I keep the docker-compose.yaml file and the Dockerfile that should be used to build the backend code.įinally, I bind the backend/src directory into the docker container so that changes are picked up by nodemon during development and there's a quick project rebuild and restart without having to restart the docker container. I'm using a nest project and I've placed the code into a backend folder. As long as you have docker and docker-compose installed, it should all work! If you'd like to follow in the example, you can clone the GitHub repository. I've used nest as our framework since that's what is most applicable in our use cases.

webstorm node js debug

#Webstorm node js debug how to#

This article outlines how to set up debugging in a Typescript project that runs using docker containers. The tutorials were great but I couldn't find one that explained the process from start to finish, this article was what I worked off to get to this answer. So I started reading around and found that there are ways to bind to the debug ports for node projects. This means that the current solutions out there won't work for us, unless we want to run half of the stack through docker-compose and the other half directly on our PCs. Furthermore, we use docker-compose, to set up the full stack for local development. We use docker for our development environment to ensure that there is a fast setup. The problem is that that solution assumes we are running the application directly off our PCs.

webstorm node js debug

It's pretty straight forward, all you have to do is set up the execution script in Webstorm (or any IDE really) and you're good to go. I've recently been looking at how people debug Typescript applications.















Webstorm node js debug