Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import module 'index': Error #6

Closed
annasxu opened this issue May 24, 2018 · 11 comments
Closed

Unable to import module 'index': Error #6

annasxu opened this issue May 24, 2018 · 11 comments

Comments

@annasxu
Copy link

annasxu commented May 24, 2018

Hi, I followed the instructions exactly, but I'm getting the following error in the cloud log. What does it mean and how can I correct it?

Unable to import module 'index': Error
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/var/task/index.js:6:15)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

@annasxu
Copy link
Author

annasxu commented May 24, 2018

I'm also seeing the following error in my terminal:

Error(s) found in the deploy setting for the following in-skill product(s):
(Please restore the missing file or modify skill configuration file .ask/config to fix the deploy setting)

Missing file: [ID] undefined [FILE] isps/entitlement/Entitlement_Template.json

And I have updated the release date to be a future date.

@franklin-lobb
Copy link
Contributor

Normally Lambda is looking for a file in the root of the deployment package that matches the handler name. In this case, index.js. This file will export a handler function, which is invoked when Alexa passes the request to the Lambda function. In order for this to work, assuming all of the files were properly cloned, there should be an index.js file in the lambda/custom folder in your project (the project root is where the skill.json file is located, and is where you should be running the ask deploy.

Check that the index.js file is present in the lambda/custom folder (and has the code found in the repo). If it is, retry the ask deploy and look to confirm there isn't an error during the deployment.

As for the second issue, that looks to be solved here: #7.

@annasxu
Copy link
Author

annasxu commented May 29, 2018

I'm not getting any errors when I do ask deploy, but when i do ask new as per the instructions, I'm given the following set up:

screen shot 2018-05-29 at 1 28 45 am

@franklin-lobb
Copy link
Contributor

The picture you posted looks correct. (I'm using lambda/custom as shorthand to indicate there's a custom folder in the lambda folder.) The clone should result in the same as the ask new plus following the other instructions, with two exceptions: (1) the clone will pull down the isps.samples folder, but you can access those from the repo directly and they aren't used by the ask-cli directly, and (2) some github specific files like the license, pull request template, etc., which also aren't used by the ask-cli.

You indicated that the ask new resulted in the folders being setup differently. What are the differences? Are they just the extra folders/files I mentioned, or is there something different with those core files?

If you are comfortable with what the ask-cli does, you don't have to manually modify the files as described in the first section of the instructions. You can clone the repo and skip to the second section.

@annasxu
Copy link
Author

annasxu commented May 29, 2018

Thanks for your response! After searching some forums, what ended up getting rid of the module index error was changing the permissions on the files and then zipping the contents of the custom folder, and uploading that directly to my lambda console. Unfortunately, when I test the skill, I see the following:

screen shot 2018-05-29 at 2 58 45 pm

Any ideas?

@franklin-lobb
Copy link
Contributor

It looks like there isn't a call being made to the lambda function (the error is happening before that), is that correct? If so, I'm not sure what to suggest other than disabling and re-enabling the skill for testing. I have not seen this error before.

@annasxu
Copy link
Author

annasxu commented May 30, 2018

Fixed! Thank you!!

@annasxu annasxu closed this as completed May 30, 2018
@next-nurialopez
Copy link

@annasxu how did you fix it? I'm getting the same error after changing my lambda from node 4 to node 8, I just changed the runtime and I am getting that error.
What I want to do is upgrade my lambda to node 8 and in order to see what needs to change I have just started with the runtime and I get this error.
I don't know if I have to update some modules or something else for migrating my lambda.
Any help would be appreciated.
Thanks.

@hspeight
Copy link

hspeight commented Mar 7, 2019

In my case I was getting this because I tried to require something that wasn't in node_modules.

@NasreenUstad
Copy link

select all your files (index.js, node_modules, package.json) then add to the archive, what we are doing here is we are zipping the entire folder that's why AWSlambda is not able to read the index.js file.

try it and let me know.
Thanks

@franklin-lobb
Copy link
Contributor

@next-nurialopez are you having a problem with this sample, or are you just generally trying to upgrade your lambda function from node 4 to node 8? If the latter, the Alexa Forums would be a better place to ask that question.

That said, as the others have suggested, check your requires statements and confirm that the modules you are requiring are available. If you had a working function using Node 4, and all you changed was the runtime, then I would expect it to still work. Try looking at your stack trace and see if you can identify the specific line with the problem and that should provide a clue as to how to proceed. If you're not sure how to read your stack trace, you could post it here and we might be able to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants