Windows 10 64位
节点v12.16.3
无服务器1.71.3
无服务器-脱机6.1.7
目录
root:
- package.json
- /sub
-- __init__.py
-- sub_handler.py
- ...
- handler.py
- serverless.yml嗨,我目前正在尝试使用无服务器离线测试本地两个lambda函数。它适用于根目录中的处理程序,但似乎无服务器脱机不能引用子目录中的其他处理程序。
如何在子目录中引用处理程序?
PS:当部署到AWS LAMBDA时,此配置可以工作。我可以把这两条路都贴出来。
当我试图发布:hello2:时出错
脱机加载处理程序..。(C:\Users\my_user\Desktop\serverless-offline\sub\sub_handler)跟踪(最近一次调用):
文件C:\Users\my_user\Desktop\serverless-offline\node_modules\serverless-offline\dist\lambda\handler-runner\python-runner\invoke.py",第75行,在
模= import_module(args.handler_path.replace('/','.'))文件"C:\Users\my_user\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py",
第126行,在import_module中返回_bootstrap._gcd_import(namelevel:,package,level)文件"",第994行,在_gcd_import中
文件“< importlib._bootstrap>",第971行,_find_and_load文件”<冻结的importlib._bootstrap>",第953行,_find_and_load_unlocked
ModuleNotFoundError:没有名为“sub\sub_handler”的模块
serverless.yml
service: sls-offline-test
provider:
name: aws
runtime: python3.6
memorySize: 256
stage: ${opt:stage, 'dev'}
region: us-east-1
environment:
STAGE: ${self:provider.stage}
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: POST
hello2:
handler: sub/sub_handler.hello2
events:
- http:
path: 'hello2'
method: POST
package:
individually: true
include:
- sub/**
plugins:
- serverless-offline发布于 2020-06-03 21:10:24
最近,我遇到了同样的问题,我更新了无服务器离线插件的版本,并为我解决了这个问题。
https://stackoverflow.com/questions/62181576
复制相似问题