2

i've been trying to create this Amazon skill thorugh the lambda tool, but i've been getting this error:

 { "errorMessage": "Cannot find module './AlexaSkill'", "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:18)", "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)" ] } 

I've looked at all possible solutions, even zipping the file correctly (which i did and it still does not work)

Here's the error log:

START RequestId: a3b6a9d5-204c-11e7-8778-8d44331f3381 Version: $LATEST Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/var/task/index.js:2:18) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) END RequestId: a3b6a9d5-204c-11e7-8778-8d44331f3381 REPORT RequestId: a3b6a9d5-204c-11e7-8778-8d44331f3381 Duration: 57.69 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 23 MB 

Here's the code of my index.js:

 var request = require("request") , AlexaSkill = require('./AlexaSkill') , APP_ID = 'amzn1.ask.skill.xxxxxx'; var error = function (err, response, body) { console.log('ERROR [%s]', err); }; var getJsonFromUnity = function(color, shape, callback){ var command = "create " + color + " " + shape; if(color == "thank you"){ callback("thank you"); } else{ var options = { method: 'GET', url: 'https://xxxxxx.herokuapp.com/', qs: { command: command }, headers: { 'postman-token': '230914f7-c478-4f13-32fd-e6593d8db4d1', 'cache-control': 'no-cache' } }; var error_log = ""; request(options, function (error, response, body) { if (!error) { error_log = color + " " + shape; }else{ error_log = "There was a mistake"; } callback(error_log); }); } } var handleUnityRequest = function(intent, session, response){ getJsonFromUnity(intent.slots.color.value,intent.slots.shape.value, function(data){ if(data != "thank you"){ var text = 'The ' + data + ' has been created'; var reprompt = 'Which shape would you like?'; response.ask(text, reprompt); }else{ response.tell("You're welcome"); } }); }; var Unity = function(){ AlexaSkill.call(this, APP_ID); }; Unity.prototype = Object.create(AlexaSkill.prototype); Unity.prototype.constructor = Unity; Unity.prototype.eventHandlers.onSessionStarted = function(sessionStartedRequest, session){ console.log("onSessionStarted requestId: " + sessionStartedRequest.requestId + ", sessionId: " + session.sessionId); }; Unity.prototype.eventHandlers.onLaunch = function(launchRequest, session, response){ // This is when they launch the skill but don't specify what they want. var output = 'Welcome to Unity. Create any color shape by saying create and providing a color and a shape'; var reprompt = 'Which shape would you like?'; response.ask(output, reprompt); console.log("onLaunch requestId: " + launchRequest.requestId + ", sessionId: " + session.sessionId); }; Unity.prototype.intentHandlers = { GetUnityIntent: function(intent, session, response){ handleUnityRequest(intent, session, response); }, HelpIntent: function(intent, session, response){ var speechOutput = 'Create a new colored shape. Which shape would you like?'; response.ask(speechOutput); } }; exports.handler = function(event, context) { var skill = new Unity(); skill.execute(event, context); }; 

Can anyone help me and pin point me to a solution?

1 Answer 1

3

That message is telling you that the file AlexaSkill.js has not been uploaded in your zip file, or possibly that it is not in the directory specified.

Check the contents of the .zip file that you uploaded to ensure that it is included. Also make sure that it is in the same directory as index.js.

Since you are loading it using "AlexaSkill = require('./AlexaSkill')", it is expected to be in the same directory. If AlexaSkill.js is actually in a subdirectory, for example named 'src', then you would use require('./src/AlexaSkill') instead.

Note that the specified path is relative to the file containing the require() statement.

Sign up to request clarification or add additional context in comments.

1 Comment

this was exactly my issue. I was zipping from a directory higher so i was zipping the folder rather than just its contents

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.