【问题标题】:debug Server less (Node js) locally in Visual code using break points.使用断点在可视代码中本地调试 Serverless (Node js)。
【发布时间】:2018-09-19 21:07:56
【问题描述】:

我是无服务器框架的新手,正在尝试使用断点在可视代码中本地调试无服务器(Node js)。

我参考了一些文章,但对我没有太大帮助。

https://medium.com/@OneMuppet_/debugging-lambada-functions-locally-in-vscode-with-actual-break-points-deee6235f590 https://hackernoon.com/running-and-debugging-aws-lambda-functions-locally-with-the-serverless-framework-and-vs-code-a254e2011010

【问题讨论】:

  • 把你遇到的问题具体补充一下。
  • 如果您要调试的只是您的功能(而不是与平台相关的东西),为什么不直接运行一些设置 evn 变量 + 输入的代码,然后调用处理程序呢?如果您确实希望调试一些与平台相关的东西(例如事件循环、上下文相关),我不确定这是否可能。这可能会有所帮助,但我不熟悉 aws.amazon.com/about-aws/whats-new/2017/08/…

标签: node.js debugging visual-studio-code serverless-framework serverless


【解决方案1】:

最后,我能够解决问题,我缺少节点路径

{
    "version": "0.2.0",
    "configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Debug Local",
        "program": "${workspaceFolder}/node_modules/serverless/bin/serverless",
        "cwd": "${workspaceRoot}",
        "args": [
            "invoke",
            "local",
            "-f",
            "functionname",
            "--path",
            "../test.json", // pass the path of local test event
            "--stage",
            "AWs envrionment name" // eg: dev,stage, prod etc
        ],
        "env": {
            "NODE_PATH": "${cwd}"
        }
    }]
}           

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-21
    • 1970-01-01
    • 2021-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 2018-04-22
    相关资源
    最近更新 更多