2

So I am learning how to create alexa skills and I have create two sucessfully following the steps below but for some reason when I follow these steps now I am missing the node_modules folder and the package.json. This is causing the following error when I test my skill:

Unable to import module 'index': Error

The steps I am following are:
- go to the aws console select lambda
- select create new function
- blueprints -> select alexa-skill-kit-sdk-factskill -> configure
- select existing role ->  lambda_basic_execution
- create function

It was my understanding that the alexa-skill-kit-sdk-factskill came with these dependencies. Is there a way to add them in manually if so how? I have tried to find a console but I don't see where that is in the lambda workspace.

Here is a screen shots of the project where it did add the folder and json file enter image description here

Here is on of my current project enter image description here

Kris
  • 327
  • 5
  • 16

2 Answers2

1

I have had this problem, but unfortunately, Lambda console doesn't give us console to install nodejs dependencies.

So, you have to actually deploy your lambda function. There are many ways to do that, but more popular are:

  1. Node Lambda package (for node)
  2. Create ZIP and deploy it in console (Not recommended because of size limitation)
  3. AWS CLI

As you're learning the Alexa Skills, I would suggest you the way Amazon suggests devs to create and organise Alexa Skill and Lambda function.

Use ASK CLI

For creating new Alexa Skill. This will create a directory, which will have:

  1. Skill's intent Schema
  2. Skill's lambda function
  3. Plus, you can pass a template to create skill for a specific template. Here is list of templates created by Amazon devs.
  4. For eg, command for creating Skill code, for a fact-template skill

     ask new [--template [template-name] [--url <url>]] 
     [-n|--skill-name <name>] 
     [-p| --profile <profile>] [--lambda-name <lambda-name>]
    

Using ASK CLI, will give you the advantage of deploying your skill and lambda simultaneously.

I know ASK CLI is a lot to take in so quickly, but once you get the hang of it, it is a very useful tool for Alexa developers.

Mukul Jain
  • 1,121
  • 11
  • 24
0

You can zip the whole directory content locally and upload the zip to lambda. But yeah you can't edit the code in the console then.

Remember that your handler file name must be mentioned as it is in Handler section. Like if your file name is app.js then app.handler.

Rahul
  • 863
  • 6
  • 23