gpt4 book ai didi

javascript - 无法在 Lambda 中导入模块

转载 作者:搜寻专家 更新时间:2023-11-01 04:35:46 24 4
gpt4 key购买 nike

我有一个简单的 exports.js 文件,我已经压缩了文件夹并将其上传到 Lambda,但在运行时它给出了一个错误:

"errorMessage": "Cannot find module 'exports'",
"errorType": "Error",
"stackTrace":
[
"Function.Module._resolveFilename (module.js:338:15)",
"Function.Module._load (module.js:280:25)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)"
]

如有任何帮助,我们将不胜感激。谢谢

最佳答案

1.将文件命名为exports.js

2.在文件中命名处理程序,exports.handler

exports.handler = function (event, context) 
{
var YourSkill = new YourSkill();
YourSkill.execute(event, context);
}

3.将lambda config中的handler设置为exports.handler

4.只压缩文件夹的内容,如果你压缩文件夹也找不到你的文件。

5.重命名压缩文件exports.zip

关于javascript - 无法在 Lambda 中导入模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35854832/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com