0

This is my first time use debugger on Visual Studio Code. I am working on a asp.net-react webapi. I was easily able to use debugger for .net Core. Here is my launch.json:

{ 
    "version": "0.2.0", 
    "configurations": [ 
         { 
             // Use IntelliSense to find out which attributes exist for C# debugging 
             // Use hover for the description of the existing attributes 
             // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 
             "name": ".NET Core Launch (web)", 
             "type": "coreclr", 
             "request": "launch", 
             "preLaunchTask": "build", 
            // If you have changed target frameworks, make sure to update the program path. 
             "program": "${workspaceFolder}/API/bin/Debug/net6.0/API.dll", 
             "args": [], 
             "cwd": "${workspaceFolder}/API", 
             "stopAtEntry": false, 
             // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 
             "serverReadyAction": { 
                 "action": "openExternally", 
                 "pattern": "\bNow listening on:\s+(https?://\S+)" 
             }, 
             "env": { 
                 "ASPNETCORE_ENVIRONMENT": "Development" 
             }, 
             "sourceFileMap": { 
                 "/Views": "${workspaceFolder}/Views" 
             } 
         }, 
         { 
             "name": ".NET Core Attach", 
             "type": "coreclr", 
             "request": "attach" 
         } 
     ] 
}

Then I wanted to use debugger for node. I watched some videos from youtube but none of them worked. I also followed this link https://code.visualstudio.com/docs/editor/debugging, followed his steps but I nothing worked. I tried on launch, on attach, but the debugger doesn't even start. I added a onlaunch configuration:

{ 
    "name": "Launch Program", 
    "program": "${workspaceFolder}/app.js", 
    "request": "launch", 
    "skipFiles": [ "<node_internals>/**" ], 
    "type": "node" 
},

and it threw me this error on debug console:

C:\Program Files\nodejs\node.exe .\app.js 
Process exited with code 1 Uncaught Error 
Error: Cannot find module 
'c:\Users\Lenovo\Desktop\Student\app.js' at 
    Module._resolveFilename (internal/modules/cjs/loader:933:15) at 
    Module._load (internal/modules/cjs/loader:778:27) at 
    executeUserEntryPoint (internal/modules/run_main:77:12) at 
    (internal/main/run_main_module:17:47) 
No debugger available, can not send 'variables'

When I use onattach configuration:

{ 
    "name": "Attach", 
    "port": 3000, 
    "request": "attach", 
    "skipFiles": [ "<node_internals>/**" ], 
    "type": "node" 
},

it doesn't even throw any error, nor start debugging.

I googled and tried so many ways and nothing worked. Can anybody explain what should I do.

Thank you.

Altrit
  • 11
  • 3
  • Are the workspaceFolder and app.js file as entrypoint ok? It tries to start at 'c:\Users\Lenovo\Desktop\Student\app.js' - is this correct? – hideous Aug 25 '22 at 18:21
  • Actually no. I updated it to route: "${workspaceFolder}/client-app/src/index.tsx" . I think it's correct now but it's throwing me another error: C:\Program Files\nodejs\node.exe .\client-app\src\index.tsx Uncaught SyntaxError c:\Users\Lenovo\Desktop\Student\client-app\src\index.tsx:1 import React from 'react'; ^^^^^ (the arrows are under the import tag of React) – Altrit Aug 27 '22 at 07:46
  • Glad that the path seems to be correct now. The new issue looks like a missing dependency. Try to install it via npm i (and check your package.json if react exists there). Otherwise open a new question please. – hideous Aug 27 '22 at 11:46
  • Yea react does exist in package.json, but it's still giving me the same error, thank you for the help though – Altrit Aug 27 '22 at 16:32
  • Does this answer your question? [VSCODE: No debug adapter, can not send 'variables'"](https://stackoverflow.com/questions/61817528/vscode-no-debug-adapter-can-not-send-variables) – starball Feb 02 '23 at 18:56

0 Answers0