本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
本地逐步调试Node.js功能
以下是如何使用MicrosoftVisualStudio代码调试Node.js功能的示例:

使用为逐步调试Node.js功能设置MicrosoftVisualStudio代码 AWS SAM CLI,请使用以下启动配置。在执行此操作之前,请设置 template.yaml
文件位于MicrosoftVisualStudio代码:
{ "version": "0.2.0", "configurations": [ { "name": "Attach to SAM CLI", "type": "node", "request": "attach", "address": "localhost", "port": 5858, // From the sam init example, it would be "${workspaceRoot}/hello-world" "localRoot": "${workspaceRoot}/{directory of node app}", "remoteRoot": "/var/task", "protocol": "inspector", "stopOnEntry": false } ] }
的 localRoot
根据 CodeUri 在 template.yaml
文件。如果在 CodeUri,这需要反映在 localRoot
.
早于7的Node.js版本(例如Node.js4.3和Node.js6.10)使用 legacy
协议,而包含7和之后的Node.js版本(例如Node.js8.10)使用 inspector
程序。务必在 protocol
启动配置的条目。这是使用MicrosoftVisualStudio代码1.26、1.27和1.28版本 legacy
和 inspector
程序。