gpt4 book ai didi

javascript - 在 Visual Studio 代码中调试不起作用

转载 作者:行者123 更新时间:2023-12-01 03:30:39 25 4
gpt4 key购买 nike

启动配置

{
// 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 代码中调试我的 React 代码时出现以下错误。实际上我已经使用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;

调试开始了。快乐编码!!

关于javascript - 在 Visual Studio 代码中调试不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44557684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com