Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Visual Studio代码-10000毫秒后无法连接到运行时进程超时_Node.js_Visual Studio Code - Fatal编程技术网

Node.js Visual Studio代码-10000毫秒后无法连接到运行时进程超时

Node.js Visual Studio代码-10000毫秒后无法连接到运行时进程超时,node.js,visual-studio-code,Node.js,Visual Studio Code,我试图在VS代码中从调试控制台启动程序,但在10000毫秒后无法连接到运行时进程超时时出错 launch.json "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "protocol": "inspector", "name": "Attach by Proce

我试图在VS代码中从调试控制台启动程序,但在10000毫秒后无法连接到运行时进程超时时出错

launch.json

   "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}"
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach",
            "port": 9229
        },
        {
            "type": "node",
            "request": "launch",
            "port":9230,
            "name": "Launch Program",
            "program": "${workspaceFolder}\\bin\\www"
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch via Babel (works)",
        "cwd": "${workspaceRoot}",
        "port": 9229,
        "program": "",
        "runtimeExecutable": "npm",
        "console": "integratedTerminal",
        "runtimeArgs": [
            "start"
        ]
    }
    ]
}
我试图用VS代码进行调试,但遇到如下错误。我是否正确配置了launch.json

“启动”类型的配置不需要指定端口。当您设置
端口
参数时,它假定您的启动配置将包括带有该端口的--inspect参数

如果出于某种原因必须指定确切的端口,则可以包括--inspect参数,如:

    {
        "type": "node",
        "request": "launch",
        "port":9230,
        "runtimeArgs": ["--inspect=9230"],
        "name": "Launch Program",
        "program": "${workspaceFolder}\\bin\\www"
    }

但我建议只从启动配置中删除“端口”。

我正在使用nodemon和babel启动visual studio代码,发现您需要确保package.json和launch.json中的配置与visual studio代码兼容

实际上,这意味着您需要找到一种配置,允许您从powershell以及windows中的gitbash启动常规配置。以下是我的想法:

在package.json中

  "scripts": {
    "start": "nodemon --inspect --exec babel-node -- index.js",
  },
在launch.json中

   "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}"
        },
        {
            "type": "node",
            "request": "attach",
            "protocol": "inspector",
            "name": "Attach",
            "port": 9229
        },
        {
            "type": "node",
            "request": "launch",
            "port":9230,
            "name": "Launch Program",
            "program": "${workspaceFolder}\\bin\\www"
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch via Babel (works)",
        "cwd": "${workspaceRoot}",
        "port": 9229,
        "program": "",
        "runtimeExecutable": "npm",
        "console": "integratedTerminal",
        "runtimeArgs": [
            "start"
        ]
    }
    ]
}
当节点启动时,您应该看到如下内容:

PS F:\noise\bookworm-api> cd 'F:\noise\bookworm-api'; & 'F:\applications\nodejs\npm.cmd' 'start'

> bookworm-api@1.0.0 start F:\noise\bookworm-api
> nodemon --inspect --exec babel-node -- index.js

[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node --inspect index.js`
Debugger listening on ws://127.0.0.1:9229/e6e1ee3c-9b55-462e-b6db-4cf67221245e
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
Running on localhost:3333
你真正想要的是:

Debugger listening on ws://127.0.0.1:9229/e6e1ee3c-9b55-462e-b6db-4cf67221245e
此输出显示调试器正在等待端口9229上的WebSockets请求。您可以通过以下方式与visual studio代码通信:

"port": 9229,
在launch.json文件中


如果没有看到调试服务器正在等待的端口,则可能需要在节点中的start命令中添加
--inspect
标志。

转到
工具->选项->调试->常规
然后禁用
我正在成功地使用它,并禁用了以下选项

在Visual Studio中,转到:
Tools->Options->debug->General

为Asp.Net(Chrome、Edge和IE)启用JavaScript调试
为ASP.NET启用旧版Chrome JavaScript调试器。

在上次调试会话中忘记关闭浏览器时,我也会遇到同样的错误。它保持与Angular代理的连接,并防止启动新的调试会话。关闭浏览器后,F5将启动一个新会话,不会出错。
打开Android Studio、配置、ADV Manager、创建或打开ADV。 在VS代码和调试中,单击模拟android cordova

命令行-cordova模拟android

{ "name": "cordova emulate android", "type": "cordova", "request": "launch", "platform": "android", "target": "emulator", "port": 9222, "sourceMaps": true, "cwd": "${workspaceRoot}", // "ionicLiveReload": true }, { “名称”:“cordova模仿android”, “类型”:“科尔多瓦”, “请求”:“启动”, “平台”:“安卓”, “目标”:“仿真器”, “端口”:9222, “源地图”:正确, “cwd”:“${workspaceRoot}”, //“ionicLiveReload”:正确 },
  • 复制
    googlechrome
    快捷方式→ <代码>itest
  • alt
    键双击
    itest

  • itest属性快捷方式目标

  • “C:\ProgramFiles(x86)\Google\Chrome\Application\Chrome.exe”--远程调试端口=6062--user data dir=“%appdata%\Google\Chrome\itest

  • VS代码,菜单调试添加配置铬:连接→ <代码>“端口”:6062,→ <代码>Ctrl+Shift+D调试→ 开关连接到Chrome开始调试

  • 在我的例子中,更新核心工具解决了这个问题

    使用以下命令进行更新:

    npm install -g azure-functions-core-tools
    

    删除launch.json文件,然后转到调试并创建新的launch.json文件

    Hi teja teja,这个问题是关于Visual Studio代码的,而不是Visual Studio。对于inspector,您还可以添加此部分“协议”:“inspector”,直接输入到配置中。在我的例子中,它有训练如果代码有异步/等待函数,应该将
    --nolazy
    标志传递给节点进程使用python调试器,这就解决了问题