javascript visual studio代码中的调试不起作用

55ooxyrt  于 2023-08-02  发布在  Java
关注(0)|答案(6)|浏览(173)

启动配置

  1. {
  2. // Use IntelliSense to learn about possible Node.js debug attributes.
  3. // Hover to view descriptions of existing attributes.
  4. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "type": "node",
  9. "request": "attach",
  10. "name": "Attach",
  11. "port": 5858
  12. },
  13. {
  14. "type": "node",
  15. "request": "launch",
  16. "name": "Launch Program",
  17. "program": "${workspaceRoot}/src/app.js",
  18. "cwd": "${workspaceRoot}"
  19. }
  20. ]
  21. }

字符串
在Visual Studio代码中调试我的React代码时,我得到以下错误。实际上,我已经用node+react创建了这个项目,并使用visual studio作为IDE,并希望调试我的代码。我已经尝试了很多,但不能成功地调试我的代码。

  1. 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.
  2. node --debug-brk=21730 --nolazy src\app.js
  3. Debugger listening on [::]:21730
  4. e:\reactjs\reactFacebook\my-app\src\app.js:1
  5. (function (exports, require, module, __filename, __dirname) { import React, { Component } from 'react';
  6. ^^^^^^
  7. SyntaxError: Unexpected token import
  8. at createScript (vm.js:56:10)
  9. at Object.runInThisContext (vm.js:97:10)
  10. at Module._compile (module.js:542:28)
  11. at Object.Module._extensions..js (module.js:579:10)
  12. at Module.load (module.js:487:32)
  13. at tryModuleLoad (module.js:446:12)
  14. at Function.Module._load (module.js:438:3)
  15. at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
  16. at ontimeout (timers.js:380:14)
  17. at tryOnTimeout (timers.js:244:5)

nhaq1z21

nhaq1z211#

我通过在我想要调试的函数中添加以下代码来解决它:

  1. debugger;

字符串
并开始调试。编码快乐!!

ztigrdn8

ztigrdn82#

对我来说,只有将cwd设置为
第一个月

nue99wik

nue99wik3#

非常简单的解决方案是->只需卸载调试器并删除launch.json文件,然后重新安装调试器,然后启动

j2datikz

j2datikz4#

要在没有launch.json的情况下在vs代码中开始调试,请执行以下操作:
后藤文件”→“首选项”→“设置”→“扩展”→“节点调试”→[选择]“打开”


的数据

r8xiu3jd

r8xiu3jd5#

我遇到了同样的问题,原来线索在控制台:检测到Node.js v6.10.2,使用旧协议调试
我使用以下步骤解决了它:

  • 关闭VS代码
  • 卸载节点
  • 使用NVM安装节点v5
  • 删除项目中的node_modules文件夹
  • 重新打开VS代码
  • 运行npm install

放置断点并重试。

k4ymrczo

k4ymrczo6#

我从.net core 3. 1升级到.net core 6,调试没有拿起我的新控制器方法。我必须将configurations下的launch.json程序关键字更新到正确的位置。我将Debug和Controllers.dll之间的值从netcoreapp3.1更改为net6.0

相关问题