[英]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.