简体   繁体   中英

debug express js application visual studio code:

I am trying to debug my express js application through visual studio code here is my launch.json

{
    "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "attach",
            "name": "Attach",
            "port": 9229
        }
    ],
    "compounds": []
}

And my application is running in port 3000 but when i run debugger i got the following error

Debugging with legacy protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:9229)

You can change request as launch,add protocol as inspector in your file and put your main server file in program, here my server file called as server.js.

 {
   "version": "0.2.0",
   "configurations": [
      {
         "type": "node",
         "request": "launch",
         "name": "Launch Program",
         "protocol": "inspector",
         "program": "${workspaceFolder}/server.js"
      }
   ]
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM