On creation of a lambda function for a Decision Tree, the execution of the Test Event generates an error.
{
"errorMessage": "Cannot find module '/var/task/index'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:417:25)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
Could someone point me in the right direction?
Links: https://developer.amazon.com/blogs/post/TxHGKH09BL2VA1/New-Alexa-Skills-Kit-Template-Step-by-Step-Guide-to-Build-a-Decision-Tree-Skill
https://github.com/tartanguru/alexa-assistant/issues/8
Related
I'm trying to do my first skill for alexa and I'm using aws lambda for logic, my problem is that when I run the test it gives me back:
{
"errorMessage": "Cannot find module 'string-similarity'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:474:25)",
"Module.require (module.js:596:17)",
"require (internal/module.js:11:18)",
"Object.<anonymous> (/var/task/index.js:3:24)",
"Module._compile (module.js:652:30)",
"Object.Module._extensions..js (module.js:663:10)",
"Module.load (module.js:565:32)",
"tryModuleLoad (module.js:505:12)",
"Function.Module._load (module.js:497:3)"
]
}
I need string-similarity to compare two strings but I do not understand how to install it in lambda.
this is my package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"alexa",
"skill"
],
"author": "",
"license": "",
"dependencies": {
"ask-sdk": "^2.0.0",
"string-similarity": "^1.2.0",
"i18next": "^10.6.0",
"i18next-sprintf-postprocessor": "^0.2.2"
}
}
and so I call the package in the index.js
'use strict';
const Alexa = require('ask-sdk');
var stringSimilarity = require('string-similarity');
...
how can i solve this error
thanks for your help and sorry for my english but I'm not a native speaker.
You are getting this error because you are using 'string-similarity' but you have not installed it in your project that is why it is giving you "errorMessage": "Cannot find module 'string-similarity'".
You can not add Node Modules directly in Lambda function. If you need to use external modules/libraries you need to have your project in local machine so you can npm install the required modules an then upload the .ZIP file of your project in lambda function see details HERE.
Alternatively you can use ASK CLI to write your code some editor of your choice and deploy the lambda function with a simple command.
I'm getting this error when I upload and test my AWS Lambda function.
{
"errorMessage": "Cannot find module 'ical'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:417:25)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/index.js:2:14)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)"
]
}
Can you please help me to solve this error.
Please Make sure node_moduels directory is readable
chmod -R +r node_modules
When I am trying to run the following code from
https://github.com/awslabs/aws-config-rules/blob/master/python/iam-inactive-user.py
I am receiving below-mentioned error. Tried to
{
"stackTrace": [
[
"/var/task/lambda_function.py",
40,
"lambda_handler",
"invoking_event = json.loads(event[\"invokingEvent\"])"
]
],
"errorType": "TypeError",
"errorMessage": "'int' object has no attribute '__getitem__'"
}
I was following the Alexa Trivia Skill tutorial on GitHub (https://github.com/alexa/skill-sample-nodejs-trivia) and I followed the instructions and during testing I got Remote Endpoint could not be found... so then I done further testing in AWS Lambda and I got the following Error:
{
"errorMessage": "Cannot find module './question'",
"errorType": "Error",
"stackTrace": [
"require (internal/module.js:20:19)",
"Object. (/var/task/index.js:16:19)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)"
]
}
The Link to the AWS Lambda code is : https://github.com/alexa/skill-sample-nodejs-trivia/blob/master/lambda/custom/index.js
Any Help will be Greatly Appriciated!
Thanks
Anush
I am trying to do a simple require of my own lib in AWS Lambda, but it can't find it. What am I missing?
var a = require('./lib/a');
exports.handler = function(event, context, callback) {
callback(null, 'Testing');
}
Yeah, this works when testing it locally, but not when zipped and deployed. I am zipping just the file, not the directory and removing the require makes it work.
{
"errorMessage": "Cannot find module './lib/a'",
"errorType": "Error",
"stackTrace": [
"Function.Module._load (module.js:417:25)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/index.js:1:77)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)"
]
}
Directory structure:
index.js
lib/a.js
I am zipping just the file
Try to download your package from the AWS Lambda console. You'll receive a zip file and try to extract that on your local machine. Can you see the lib folder with a.js inside it?
Chances are, the zip file that you uploaded probably missed the lib directory.