加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

无法在Windows 10上使用VS Code调试Node.js Google Cloud Functi

发布时间:2020-12-14 05:39:02 所属栏目:Windows 来源:网络整理
导读:我正在尝试设置 local emulator for Google Cloud Functions并启用VS Code调试功能.这是一个巨大的麻烦,可能是函数模拟器中的一个错误…… 我按照这个指南来写了这封信:https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Debugging-wi
我正在尝试设置 local emulator for Google Cloud Functions并启用VS Code调试功能.这是一个巨大的麻烦,可能是函数模拟器中的一个错误……

我按照这个指南来写了这封信:https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki/Debugging-with-Visual-Studio-Code.

当地环境:

> Microsoft Windows [版本10.0.15063]
> Visual Studio Code 1.13.1(关闭任何第三方扩展)
>使用节点6.9.1的NVM

可重复的步骤:

1.为Google Cloud Functions安装本地模拟器:npm install -g @ google-cloud / functions-emulator

2.创建基本功能:

exports.dbug = (req,res) => {
    var debugTest = 'Breakpoint'
    console.log('Debug breakpoint.')
    res.send('Response success.').status(200)}

3.启动模拟器,部署函数,测试它:函数启动,函数部署dbug –trigger-http,函数调用dbug

enter image description here

4.安装VS Code调试器. launch.json:

"version": "0.2.0","configurations": [
    {
        "type": "node","request": "attach","name": "Debug Functions","processId": "${command:PickProcess}","port": 5858
    }
]

5.启动函数调试器:函数debug dbug

6.启动VS Code调试器:

enter image description here

7.添加断点:

enter image description here

8.调用函数:函数调用dbug.在这一点上,终端棒,我不知道发生了什么.它似乎没有超时,所以我最终终止它.函数模拟器似乎在此之后完全挂起,我必须从任务管理器手动终止node.js进程.

enter image description here

我尝试过其他一些方法:

>重启一切.然后启动函数,附加VS Code调试器,调用函数(不要执行函数调试.由于某种原因,这暂停在net.js中的一步.当我继续时,它不会在函数的断点处停止并且函数响应一般.

enter image description here


>完全遵循本教程:https://www.youtube.com/watch?v=5CZ1f6wzn4Q
>安装和添加@ google / cloud-debug似乎没有在本地更改任何内容.

解决方法

对于其他人看到这个线程.使用函数检查myFunc并运行Debug:附加到VS Code中的Node Process,使用–inspect标志附加到进程并正常设置断点.运行函数调用myFunc来执行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读