2017-06-15 70 views
0

啓動配置調試在Visual Studio代碼是不工作

{ 
    // 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) 
+0

可能與[VS代碼問題#24764](https://github.com/Microsoft/vscode/issues/24764)相關。正如問題中提到的,嘗試在你的'launch.json'中添加''protocol':「inspector」'。 – putu

回答

0

我有同樣的問題,原來的線索是在控制檯:調試與傳統的協議,因爲Node.js的v6.10.2檢測

我解決它使用以下步驟:

  • 關機VS代碼
  • 卸載節點
  • 安裝節點V5使用NVM
  • 刪除node_modules項目文件夾
  • 重新打開VS代碼
  • 運行npm install

放置一個斷點,然後重試。

相關問題