Reputation: 11493
I wrote a simple Alexa skill. It uses "alexa-app" as dependency.
var alexa = require('alexa-app');
When I save and test my skill I get the following response
{
"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)"
]
}
Is it possible to use this "alexa-app" dependency without baking it into a zip file. To make development quicker I'd prefer working with just one file in the online Lambda code editor. Is this possible?
Upvotes: 2
Views: 547
Reputation: 1164
No, you will need to include it in a zip along with any other files. It really isn't difficult to do though. You can use the AWS CLI to simplify this.
Here is a bash script that I use on my Mac for doing this:
# 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
In the above script, It's packaging up an index.js file along with all the files in the ./src and ./node_modules directories. It is uploading them to my 'ronsSkill' Lambda function. I use alexa-app also, and it is included in the node_modules directory by npm.
Upvotes: 5