“错误找不到模块'/ var / task / index” AWS Lambda

时间:2019-12-06 17:43:15

标签: node.js amazon-web-services alexa-skills-kit alexa-skill

我目前正在通过Powershell编写Node.js Alexa技能,并且我一直在尝试编写一个可以将回声点用作夜灯的函数。我通过github克隆了这项技能。 代码是:

import { SkillBuilders } from "ask-sdk-core";
import { AmazonCancelAndStopIntentHandler } from "./handlers/AMAZON_CancelAndStopIntentHandler";
import { AmazonHelpIntentHandler } from "./handlers/AMAZON_HelpIntentHandler";
import { CustomErrorHandler } from "./handlers/CustomErrorHandler";
import { GameEngineInputHandler } from "./handlers/GameEngine_InputHandler";
import { LaunchRequestHandler } from "./handlers/LaunchRequestHandler";
import { SessionEndedHandler } from "./handlers/SessionEndedHandler";
import { TimeIntentHandler } from "./handlers/TimeIntentHandler";
import { LogInterceptor } from "./interceptors/LogInterceptor";

export const handler = SkillBuilders.custom()
    .addRequestHandlers(
        new AmazonCancelAndStopIntentHandler(),
        new AmazonHelpIntentHandler(),
        new LaunchRequestHandler(),
        new SessionEndedHandler(),
        new TimeIntentHandler(),
        new GameEngineInputHandler(),
    )
    .addErrorHandlers(
        new CustomErrorHandler(),
    )
    .addRequestInterceptors(
        new LogInterceptor(),
    )
    .addResponseInterceptors(
        new LogInterceptor(),
    )
    .lambda();`

当我通过ask deploy上传或压缩并通过aws lambda上传时,出现此错误

{
  "errorMessage": "Cannot find module '/var/task/index'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:474:25)",

    "Module.require (module.js:596:17)",
    "require (internal/module.js:11:18)"
  ]
}

这是工厂日志

START RequestId: 68837f04-333e-453f-b643-1818f2a33807 Version: $LATEST
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)
END RequestId: 68837f04-333e-453f-b643-1818f2a33807
REPORT RequestId: 68837f04-333e-453f-b643-1818f2a33807  Duration: 53.20 ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 58 MB  Init Duration: 0.98 ms  

我尝试仅压缩文件,将权限授予node_modules文件夹,检查了index.hadler并安装了module-js,请求模块和许多其他Node模块。

这是我的目录

│   index.ts
│   package-lock.json
│   package.json
│   
├───handlers
│       AMAZON_CancelAndStopIntentHandler.ts
│       AMAZON_HelpIntentHandler.ts
│       CustomErrorHandler.ts
│       GameEngine_InputHandler.ts
│       LaunchRequestHandler.ts
│       SessionEndedHandler.ts
│       TimeIntentHandler.ts
│       
├───interceptors
│       LogInterceptor.ts
│       
├───node_modules
│        
└───utils
        ColorCycle.ts
        Constants.ts
        Directives.ts
        SilenceGenerator.ts

0 个答案:

没有答案