VSCode Serverless ExpressJS Typescript 应用程序中的断点不起作用
VSCode Breakpoint in Serverless ExpressJS Typescript App Doesn't Work
我无法在使用无服务器框架将代码部署到 AWS Lambda 的打字稿中编写的 ExpressJS 应用程序中设置 VSCode 中的断点。
我正在使用 serverless-plugin-typescript 将 typescript 编译到一个 .build
文件夹中,地图文件在该文件夹中生成并与编译后的 js 文件一起存储。
我的调试器 运行s serverless offline
到 运行 本地程序。如果我在 .build/src/controllers.js
文件中设置断点,它将命中该断点,但如果我在未编译版本中设置它则不会。
我的项目文件夹结构是这样的:
api/
--.build/
---- src/
------ config/
------ controllers/
--------- controller.js
--------- controller.js.map
------ interfaces/
------ services/
------ index.js
-- src/
---- config/
---- controllers/
------ controller.ts
---- interfaces/
---- services/
---- index.ts
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": ".build",
"baseUrl": ".",
"preserveConstEnums": true,
"strictNullChecks": true,
"allowJs": true,
"rootDir": "./",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
serverless.yaml
service: api
plugins:
- serverless-plugin-typescript
- serverless-offline
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: 20201221
memorySize: 192
timeout: 10
versionFunctions: false
region: us-east-1
profile: xxxxxxx
stage: dev
environment:
NODE_ENV: ${opt:env, 'local'}
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 'dynamodb:*'
Resource:
- '*'
custom:
serverless-offline:
noPrependStageInUrl: true
functions:
express:
handler: src/index.handler
package:
include:
- src/**
events:
- http:
method: ANY
path: /{proxy+}
cors: true
- http:
method: ANY
path: /
cors: true
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "API Debug",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}/api",
"runtimeExecutable": "node",
"runtimeVersion":"14.17.0",
"runtimeArgs": ["--lazy"],
"skipFiles": ["<node_internals>/**"],
"args": [
"offline",
"--noPrependStageInUrl"
],
"program": "${workspaceRoot}/api/node_modules/.bin/serverless",
"console": "integratedTerminal",
"sourceMaps": true,
"smartStep": false,
"stopOnEntry": false,
"outFiles": [
"${cwd}/.build/src/**/*"
],
"protocol": "inspector",
"env": {
"NODE_ENV": "development"
},
"autoAttachChildProcesses": true,
},
]
}
VSCode Version: 1.60.0
TypeScript 4.3.5
Node 14.x.x
非常感谢任何帮助。谢谢。
已更改
"outFiles": [
"${cwd}/api/.build/src/**/*"
],
至
"outFiles": [
"${workspaceRoot}/api/.build/src/**/*"
],
它解决了问题
我无法在使用无服务器框架将代码部署到 AWS Lambda 的打字稿中编写的 ExpressJS 应用程序中设置 VSCode 中的断点。
我正在使用 serverless-plugin-typescript 将 typescript 编译到一个 .build
文件夹中,地图文件在该文件夹中生成并与编译后的 js 文件一起存储。
我的调试器 运行s serverless offline
到 运行 本地程序。如果我在 .build/src/controllers.js
文件中设置断点,它将命中该断点,但如果我在未编译版本中设置它则不会。
我的项目文件夹结构是这样的:
api/
--.build/
---- src/
------ config/
------ controllers/
--------- controller.js
--------- controller.js.map
------ interfaces/
------ services/
------ index.js
-- src/
---- config/
---- controllers/
------ controller.ts
---- interfaces/
---- services/
---- index.ts
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": ".build",
"baseUrl": ".",
"preserveConstEnums": true,
"strictNullChecks": true,
"allowJs": true,
"rootDir": "./",
"paths": {
"*": [
"node_modules/*"
]
}
},
"include": [
"src/**/*"
]
}
serverless.yaml
service: api
plugins:
- serverless-plugin-typescript
- serverless-offline
provider:
name: aws
runtime: nodejs14.x
lambdaHashingVersion: 20201221
memorySize: 192
timeout: 10
versionFunctions: false
region: us-east-1
profile: xxxxxxx
stage: dev
environment:
NODE_ENV: ${opt:env, 'local'}
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 'dynamodb:*'
Resource:
- '*'
custom:
serverless-offline:
noPrependStageInUrl: true
functions:
express:
handler: src/index.handler
package:
include:
- src/**
events:
- http:
method: ANY
path: /{proxy+}
cors: true
- http:
method: ANY
path: /
cors: true
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "API Debug",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}/api",
"runtimeExecutable": "node",
"runtimeVersion":"14.17.0",
"runtimeArgs": ["--lazy"],
"skipFiles": ["<node_internals>/**"],
"args": [
"offline",
"--noPrependStageInUrl"
],
"program": "${workspaceRoot}/api/node_modules/.bin/serverless",
"console": "integratedTerminal",
"sourceMaps": true,
"smartStep": false,
"stopOnEntry": false,
"outFiles": [
"${cwd}/.build/src/**/*"
],
"protocol": "inspector",
"env": {
"NODE_ENV": "development"
},
"autoAttachChildProcesses": true,
},
]
}
VSCode Version: 1.60.0
TypeScript 4.3.5
Node 14.x.x
非常感谢任何帮助。谢谢。
已更改
"outFiles": [
"${cwd}/api/.build/src/**/*"
],
至
"outFiles": [
"${workspaceRoot}/api/.build/src/**/*"
],
它解决了问题