首页 > 解决方案 > 使用断点在可视代码中本地调试 Serverless (Node js)。

问题描述

我是无服务器框架的新手,正在尝试使用断点在可视代码中本地调试无服务器(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-本地功能与无服务器框架和 vs-code-a254e2011010

标签: node.jsdebuggingvisual-studio-codeserverless-frameworkserverless

解决方案


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

{
    "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}"
        }
    }]
}           

推荐阅读