<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[VSCodeTips - Medium]]></title>
        <description><![CDATA[To share the tips on VSCode - Medium]]></description>
        <link>https://medium.com/vscodetips?source=rss----f5f1868c7ee0---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>VSCodeTips - Medium</title>
            <link>https://medium.com/vscodetips?source=rss----f5f1868c7ee0---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 14:50:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/vscodetips" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Debugging a NodeJS application in VSCode]]></title>
            <link>https://medium.com/vscodetips/debugging-a-nodejs-application-in-vscode-e4da0a164e9a?source=rss----f5f1868c7ee0---4</link>
            <guid isPermaLink="false">https://medium.com/p/e4da0a164e9a</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nodemon]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Shriram Manoharan]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 00:34:25 GMT</pubDate>
            <atom:updated>2021-10-19T07:05:07.744Z</atom:updated>
            <content:encoded><![CDATA[<h3>Configuring VSCode for Debugging NodeJS Applications</h3><p>If you are someone, who likes to use VSCode for NodeJS development, you might have gone through the pain of Debugging it. Though for smaller application, it could be easier to go through the code, compare the data with code and analyse, it could be difficult to keep track as the code base increases in size.</p><p>In this page, we will look at</p><ol><li>Console.debug</li><li>Debugging using Unit Tests</li><li>Express server debugging</li></ol><p>Lets consider a simple code as an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*2EBNrZk8gGdKEitq9H7Vcw.png" /><figcaption>functionToTest.js</figcaption></figure><p>and in an another file we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*_HpH0ouF9q7iTWOvFknWYw.png" /><figcaption>userInformation.js</figcaption></figure><h3><strong>Issue:</strong></h3><p>For the example let’s take a smaller issue: When a user’s status is requested with { userId: &quot;1&quot;} , the inActive is returned from the function. However active is expected.</p><p>Reason for issue: Due to the use of ===, “1” will not be equal to 1.</p><p>Now lets start debugging to find the root cause:</p><h3>Console.debug</h3><p>The basic way to debug is by using console.debug statement. Though it serves the purpose, it will be a time consuming process to add new logs or update existing ones to print more information. For every additional data needed, the statements have to be changed and the application needs to be rerun. And finally, the cleanup of these logs is an additional task.</p><p>The same code above with the debug statements will now be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*-XeaLNX0ZHJBpE42efG9AA.png" /><figcaption>Console.debug</figcaption></figure><p>As highlighted, the user information is printed as undefined. To further investigate, we will have to add more logs and the function has to be rerun until the cause is found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*c1QUIgsZnvwdT4brLtiLTQ.png" /><figcaption>More Logs added to the functions</figcaption></figure><h3>Debugging using Unit tests</h3><p>Debugging with the help of unit test will be a lot easier, especially when the code is covered by it. We could easily stub the downstream services or db values with actual data and check. For this example, we will use Jest module.</p><p>The test file: The test data will be our example data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*uuO554PKHYQCBsSmmZTx4Q.png" /><figcaption>functionToTest.test.js</figcaption></figure><p>Debugger config for Jest:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*OOFHRv84iiToTD0zMeHC_A.png" /><figcaption>Jest Debugging Config</figcaption></figure><p>From the above image you could see that we have set the program to use Jest and the test file to run is set at args. If your test file has more than one tests for the same function, make sure you have added .only to the it/describe. That way, only the test you intend to run will be executed.</p><p>All set, lets setup a breakpoint and start debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThzgR1aSYpv89maVgqfzaA.png" /><figcaption>Debug data</figcaption></figure><p>As you could see, with the help of unit test we will be able to set up debugging quite easily and analyse. All the variables in the current function will be shown in the Variables. If additional data is needed to be tracked, it could be added to the Watch as shown. Also, we could hover over the variables to check its value.</p><p>A disadvantage to this method would be, if we have multiple downstream services call or database query is involved, we will have to update the mock with the actual data we have to analyse.</p><h3>Express server debugging</h3><p>If Express is used in the application and an end to end debugging is necessary, we could set it up using nodemon. The config will look like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4_oBifas4vMCewWpiY-Nw.png" /><figcaption>Nodemon setup</figcaption></figure><p>This way the debugger will start listening to the port specified and any request that comes in to the server will stop at the debug point. To edit any values during debugging, it can be done so by setting them in the “Variables” section in the Debug console.</p><p>The code used in the example above can be found <a href="https://github.com/shrirammano/vscode-debugger/tree/master">here</a>.</p><p>Checkout how to debug an express server in detail <a href="https://medium.com/@shrirammano/express-application-debugging-in-vscode-60453b95b">here</a>.</p><p>Please comment below if you have other easy ways to debug NodeJS applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4da0a164e9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/vscodetips/debugging-a-nodejs-application-in-vscode-e4da0a164e9a">Debugging a NodeJS application in VSCode</a> was originally published in <a href="https://medium.com/vscodetips">VSCodeTips</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Git Stash and using it easily in VSCode]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/vscodetips/understanding-git-stash-and-using-it-easily-in-vscode-7da049160097?source=rss----f5f1868c7ee0---4"><img src="https://cdn-images-1.medium.com/max/2600/1*S4lK60tRx861XaMP9bE59g.jpeg" width="3316"></a></p><p class="medium-feed-snippet">Git is used as the Version Control system in projects of different sizes. As developers, when we work on the code, we do the necessary&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/vscodetips/understanding-git-stash-and-using-it-easily-in-vscode-7da049160097?source=rss----f5f1868c7ee0---4">Continue reading on VSCodeTips »</a></p></div>]]></description>
            <link>https://medium.com/vscodetips/understanding-git-stash-and-using-it-easily-in-vscode-7da049160097?source=rss----f5f1868c7ee0---4</link>
            <guid isPermaLink="false">https://medium.com/p/7da049160097</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[productivity-hacks]]></category>
            <dc:creator><![CDATA[Shriram Manoharan]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 00:33:45 GMT</pubDate>
            <atom:updated>2023-08-22T02:31:31.115Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Express application debugging in VSCode]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/vscodetips/express-application-debugging-in-vscode-60453b95b?source=rss----f5f1868c7ee0---4"><img src="https://cdn-images-1.medium.com/max/1621/1*dSF7gRDLBBvnu5CzimPPWg.png" width="1621"></a></p><p class="medium-feed-snippet">Debugging a small NodeJS application or a function where the issue is suspected, could be easy with simple methods. However in an Express&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/vscodetips/express-application-debugging-in-vscode-60453b95b?source=rss----f5f1868c7ee0---4">Continue reading on VSCodeTips »</a></p></div>]]></description>
            <link>https://medium.com/vscodetips/express-application-debugging-in-vscode-60453b95b?source=rss----f5f1868c7ee0---4</link>
            <guid isPermaLink="false">https://medium.com/p/60453b95b</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Shriram Manoharan]]></dc:creator>
            <pubDate>Fri, 25 Aug 2023 00:33:11 GMT</pubDate>
            <atom:updated>2021-10-12T05:41:07.147Z</atom:updated>
        </item>
    </channel>
</rss>