Launch Configuration
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 5858
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/src/app.js",
"cwd": "${workspaceRoot}"
}
]
}
I am getting the following error while debugging my react code in visual studio code. Actually I have created the project with node+react and use visual studio as IDE and want to debug my code. I have tried a lot but not able to success to debug my code.
Debugging with legacy protocol because Node.js v6.10.2 was detected.Program path uses differently cased character as file on disk; this might result in breakpoints not being hit.
node --debug-brk=21730 --nolazy src\app.js
Debugger listening on [::]:21730
e:\reactjs\reactFacebook\my-app\src\app.js:1
(function (exports, require, module, __filename, __dirname) { import React, { Component } from 'react';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:380:14)
at tryOnTimeout (timers.js:244:5)
I resolved it by adding below code inside the function which I want to debug:
debugger;
and debugging started. Happy coding!!
For start debugging in vs code without launch.json,
Goto File → Preferences → Settings → Extensions → Node Debug →[select ] "ON"
I had the same issue, turns out the clue was in the console: Debugging with legacy protocol because Node.js v6.10.2 was detected .
I resolved it using the following steps:
npm install
Place a breakpoint and try again.
非常简单的解决方案是->只需卸载调试器并删除launch.json文件,然后重新安装调试器然后启动
对我来说,调试只能在 cwd 设置为
"cwd": "${workspaceRoot}/src"
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.