PHPSTORM DEBUG CODE
See Managing plugins for details.Ĭompile your TypeScript code into JavaScript, see Compiling TypeScript into JavaScript for details.Ĭreate a Node.js run/debug configuration: Make sure the Node.js plugin is enabled on the Settings/Preferences | Plugins page, tab Installed. Make sure you have Node.js on your computer. Before running or debugging, your TypeScript code has to be compiled into JavaScript, as described in Compiling TypeScript into JavaScript. With PhpStorm, you can launch server-side TypeScript code on Node.js via the Node.js run configuration. Running and debugging a server-side TypeScript application with Node.js In the Debug tool window, proceed as usual: step through the program, pause and resume the program execution, examine it when suspended, view actual HTML DOM, run JavaScript code snippets in the Console, and so on. The URL address specified in the run configuration opens in the chosen browser and the Debug tool window appears. Select the newly created configuration from the Select run/debug configuration list on the toolbar and click next to the list. This URL can be copied from the address bar of your browser as described in Step 3 above. In the Run/Debug Configuration: JavaScript Debug dialog that opens, specify the URL address at which the application is running.
In the Edit Configurations dialog that opens, click on the toolbar and select JavaScript Debug from the list. Alternatively, select Edit Configurations from the list on the toolbar. When the development server is ready, copy the URL address at which the application is running in the browser - you will need to specify this URL address in the run/debug configuration.įrom the main menu, select Run | Edit Configurations. Most often, at this stage TypeScript is compiled into JavaScript and source maps are generated, see Compiling TypeScript into JavaScript for details. Often you need to run npm start for that. Run the application in the development mode. Debug a TypeScript application running on an external web serverĬonfigure the built-in debugger as described in Configuring JavaScript debugger.Ĭonfigure and set breakpoints in the TypeScript code. If your application is running on the built-in PhpStorm server, see Running a client-side TypeScript application above, you can also debug it in the same way as JavaScript running on the built-in server. Most often, you may want to debug a client-side application running on an external development web server, for example, powered by Node.js. Click the icon that indicates the desired browser.ĭebugging a client-side TypeScript application Hover your mouse pointer over the code to show the browser icons bar. Then select the desired browser from the list. This HTML file does not necessarily have to be the one that implements the starting page of the application.Ĭhoose View | Open in Browser from the main menu or press Alt+F2. In the editor, open the HTML file with a reference to the generated JavaScript file. The only difference is that you can set breakpoints right in the TypeScript code.Ĭompile the TypeScript code into JavaScript. You can write a client-side application in TypeScript, compile the code as described in Compiling TypeScript into JavaScript, and then run and debug your application exactly in the same way as client-side applications written in JavaScript. Running a client-side TypeScript application As a result, you can set breakpoints in your TypeScript code, launch the application with the run/debug configuration of the type JavaScript Debug (for client-side code) or Node.js, and then step through your original TypeScript code, thanks to generated sourcemaps. You can do that using the built-in TypeScript compiler and other tools, including ts-node for running TypeScript with Node.js, used separately or as part of build process.ĭuring compilation, there can also be generated source maps that set correspondence between your TypeScript code and the JavaScript code that is actually executed. With PhpStorm, you can run and debug client-side TypeScript code and TypeScript code running in Node.js.ĭebugging of TypeScript client-side code is only supported in Google Chrome and in other Chromium-based browsers.įor information on running and debugging TypeScript with Angular, see Running and debugging Angular applications.īefore running or debugging an application, you need to compile your TypeScript code into JavaScript.