2017-06-15 71 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

放置一个断点,然后重试。

相关问题