[英]Debug in visual studio code is not working
启动配置
{
// 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}"
}
]
}
在 Visual Studio 代码中调试我的反应代码时出现以下错误。 实际上,我已经使用 node+react 创建了项目,并使用 Visual Studio 作为 IDE,并想调试我的代码。 我已经尝试了很多但无法成功调试我的代码。
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)
我通过在要调试的函数中添加以下代码来解决它:
debugger;
并开始调试。 快乐编码!!
我遇到了同样的问题,结果提示在控制台中: Debugging with legacy protocol because Node.js v6.10.2 was detected 。
我使用以下步骤解决了它:
npm install
放置一个断点并重试。
非常简单的解决方案是->只需卸载调试器并删除launch.json文件,然后重新安装调试器然后启动
对我来说,调试只能在 cwd 设置为
"cwd": "${workspaceRoot}/src"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.