1/6/2024 0 Comments Nodejs inspector![]() ![]() The debug mode will be displayed as shown here: The browser will show the debug notification as shown in the following image ![]() Press F5 on the other chrome instance where is entered, the code will enter the debug mode. The breakpoint line will be displayed on the right side panel under breakpoints section, as shown in the following image: The right hand side shows Call Stack, Scope variables, breakpoints, etc.Īpply a breakpoint on a line in app.js for e.g. This shows the project stricture on the left-side in Sources panel. This will show the following source file in the chrome debugger started using node inspector as of Step 7 as shown in the following image: Step 9: In another instance of the chrome browser, enter the following link Step 8: Open the command prompt as explained in Step 2 and run the following command: Step 7: Open Chrome browser and enter the address provided in the above image to start debugging in your browser: This will show the following debugging details as shown in the following image: To start the node inspector, run the following command from the command prompt: Step 6: To use Node-Inspector, run the following command from the Command prompt: Step 5: Now assuming you have already installed node-inspector, open the Chrome browser and enter the following result will be displayed Step 4: To execute the app from the command prompt, which we opened using Step 2, enter the following command: When the request is made on it returns Employees data in a JSON format. Using the createServer() function and listen() function, it performs request processing and starts listening on port 5050. The above code creates a web server using http module. Step 3: Add the following code in app.js: We can configure Node.js intellisense from this command prompt using the following command: Step 2: Right click on app.js and select Open in Command Prompt option. In this folder add a new file of name app.js using VSCode. Open this folder in the VSCode IDE using File > Open Folder option. Step 1: Create a new folder on your hard drive called DebuggerApp. However the focus of this article is to use the browser to debug Node.js apps, hence we will be using VS Code only to develop our application and not for debugging it. Note: VS Code has the capability to debug Node.js applications. This is a free IDE for developing modern web and cloud applications and can be installed on Windows, Linux, Mac OSX. To implement our Node.js application, we will be using Visual Studio Code (VSCode). Inspect scopes, object, and variables properties.Hover mouse over on the JavaScript expressions to view values in the tooltip.Setting breakpoints for the JavaScript code.The node inspector tool provides several great features like: The debugging for JavaScript code can be started using the following command The interface for the debugger with node inspector can be started using the following command: This tool is installed using Node Package Manager via the following command You can get an overview of these tools over here. It is a debugger interface for Node.js applications that uses Blink Developer tools and is a part of the Chromium project. The node-inspector has been specifically written for debugging Node.js applications and is popular in the web community for debugging Node applications. If you plan to debug this code in a browser like Chrome, Opera or any other browser supporting WebSocket, we need a separate tool like the node-inspector. In the case of Chrome browser, the V8 debugger released as part of the Chrome Developer Tools, can be used to debug Node.js scripts. This configuration can then be processed using F10 and F11 keys. In a cross-platform IDE like Visual Studio Code (VSCode), we can make use of launch.json to define debug configuration. in case of Visual Studio 2012 onwards, we can debug JavaScript code using debugger statement. Generally while debugging JavaScript code, we can use our favorite IDE support feature for debugging. One challenge that we usually encounter while creating Node.js apps is to debug code. Node.js provides server-side JavaScript for performing various business operations ranging from HTTP request processing to database calls using Node packages. Node.js is a JavaScript runtime based on event-driven and non-IO blocking model, and can be used for building lightweight and efficient web applications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |