我写了一个简单的Alexa技巧。它使用"alexa-app“作为依赖项。
var alexa = require('alexa-app');
当我保存并测试我的技能时,我会得到以下响应
{
"errorMessage": "Cannot find module 'alexa-app'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:276:25)",
"Module.require (module.js:353:17)",
"require (internal/module.js:12:17)",
"Object.<anonymous> (/var/task/index.js:4:13)",
"Module._compile (module.js:409:26)",
"Object.Module._extensions..js (module.js:416:10)",
"Module.load (module.js:343:32)",
"Function.Module._load (module.js:300:12)",
"Module.require (module.js:353:17)"
]
}有没有可能使用这个"alexa-app“依赖项而不将其烘焙到zip文件中。为了使开发更快,我更喜欢在在线Lambda代码编辑器中只处理一个文件。这个是可能的吗?
发布于 2017-02-25 19:35:46
不,您需要将其与任何其他文件一起包含在zip中。不过,这并不难做到。您可以使用AWS CLI来简化这一过程。
下面是我在Mac上使用的bash脚本:
# Create archive if it doesn't already exist
# Generally not needed, and just a refresh is performed
if [ ! -f ./Archive.zip ];
then
echo "Creating Lambda.zip"
else
echo "Updating existing Lambda.zip"
fi
# Update and upload new archive
zip -u -r Lambda.zip index.js src node_modules
echo "Uploading Lambda.zip to AWS Lambda";
aws lambda update-function-code --function-name ronsSkill --zip-file fileb://Lambda.zip在上面的脚本中,它打包了一个index.js文件以及./src和./node_modules目录中的所有文件。它正在将它们上传到我的'ronsSkill‘Lambda函数。我也使用alexa-app,npm将其包含在node_modules目录中。
https://stackoverflow.com/questions/42450189
复制相似问题