我使用的是非常简单的设置,但是我正在使用typescript。我目前将我的typescript编译到/dist
目录中。
在尝试使用Webstorm进行调试时,我让它很容易地找到了处理程序:
但是当我运行它时,我会得到以下错误:
2021-07-01T19:48:54.216Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError","errorMessage":"错误: 找不到模块“index”\n要求堆栈:\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","stack":["Runtime.ImportModuleError: Error: Cannot find module 'index'","Require stack:","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.load (/var/runtime/UserFunction.js:140:17)"," at Object. (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:1060:14)"," at Object..js (internal/modules/cjs/loader.js:1092:10)"," at Module.load (internal/modules/cjs/loader.js:928:32)"," at Function._load (internal/modules/cjs/loader.js:769:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)"," at internal/main/run_main_module.js:17:47"]}
我也将template.yaml复制到dist
目录中。template.yaml文件如下:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
my-lambda-function
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: .
Handler: index.handler
Runtime: nodejs14.x
非常基础。
./dist
目录结构如下:
./dist
|
|- /node_modules
|- index.js
|- package.json
|- template.yaml