无法使用无服务器中的WebStorm中调试Node.js应用程序

发布于 2025-02-14 02:13:15 字数 1645 浏览 0 评论 0 原文

我目前正在node.js创建lambda函数,并希望在本地调试代码。我正在使用webstorm作为我的IDE。

serverless.yml中

service: applicationsync
frameworkVersion: '3'
provider:
  name: aws
  runtime: nodejs12.x


plugins:
  - serverless-offline

functions:
  hello:
    handler: index.handler
    events:
      - http:
          path: hello
          method: get
      - http:
          path: hello

在我的package.json中的

{
  "name": "applicationsync",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./node_modules/.bin/serverless offline -s dev",
    "debug": "set SLS_DEBUG=* && node --inspect /usr/lib/node_modules/serverless/bin/serverless offline -s dev"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "serverless-offline": "^8.8.0"
  },
  "dependencies": {
    "aws-sdk": "^2.1170.0",
    "mysql": "^2.18.1"
  }
}

,然后我添加了一些屏幕截图。

我单击调试选项:

“

以下运行:

我的文件结构:

当我发送请求时,我会收回响应,但忽略了断点,并且没有触发调试。

我想知道我缺少什么。

I am currently creating a lambda function in Node.js and want to debug the code locally. I am using WebStorm as my IDE.

In my serverless.yml

service: applicationsync
frameworkVersion: '3'
provider:
  name: aws
  runtime: nodejs12.x


plugins:
  - serverless-offline

functions:
  hello:
    handler: index.handler
    events:
      - http:
          path: hello
          method: get
      - http:
          path: hello

in my package.json

{
  "name": "applicationsync",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./node_modules/.bin/serverless offline -s dev",
    "debug": "set SLS_DEBUG=* && node --inspect /usr/lib/node_modules/serverless/bin/serverless offline -s dev"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "serverless-offline": "^8.8.0"
  },
  "dependencies": {
    "aws-sdk": "^2.1170.0",
    "mysql": "^2.18.1"
  }
}

And then I have added some screen shots.

I click on debug option:

Pic 1

The following runs:

Pic 2

My file structure:

Pic 3

When I send a request I get a response back but break points are ignored and debug is not triggered.

I am wondering what I am missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情哥ㄟ 2025-02-21 02:13:16

也许您应该尝试编辑配置... 并定期运行... 应用程序。

Maybe you should try to Edit Configurations... and regularly Run... the app. enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文