使用新的必需功能时,Alexa Lambda函数“无法导入模块'索引'”

时间:2019-01-18 13:51:17

标签: node.js requirejs axios alexa alexa-skills-kit

我正在构建Alexa技能(通过CLI部署),并且在进行一些Http调用之前,一切都进行得很顺利。

我决定先使用axios,然后再要求使用。

当我使用npm安装axios时,一切似乎都很好。仅添加“ const axios = require('axios');”这一行导致我的lambda函数开始抱怨Cloudwatch日志中的“无法导入模块'index'”,并特别在index.js中调出了我在那行中的那行require语句。

删除了axios,尝试要求...相同的交易。

有什么想法吗?

甚至还没有真正使用过这些软件包,如果我取消注释,它会在require行上抱怨。

/* eslint-disable  func-names */
/* eslint-disable  no-console */
/* eslint-disable  no-restricted-syntax */

const error_handler = require('./error_handler');
const globals = require('./globals');
const helper_functions = require('./helper_functions');
const intents_aquarium = require('./intents_aquarium');
const intents_built_in = require('./intents_built_in');
const intents_conversion = require('./intents_conversion');
const intents_helper = require('./intents_helper');
const intents_tank = require('./intents_tank');
const intents_unhandled = require('./intents_unhandled');

const skillBuilder = globals.Alexa.SkillBuilders.standard();

//const request = require('request');


exports.handler = skillBuilder
  .addRequestHandlers(
    intents_built_in.launchRequest,
    intents_built_in.exitHandler,
    intents_built_in.sessionEndedRequest,
    intents_built_in.helpIntent,
    intents_built_in.yesIntent,
    intents_built_in.noIntent,
    intents_aquarium.aquariumCreateIntentHandler,
    intents_aquarium.aquariumCreateSimpleImperial,
    intents_conversion.aquariumVolumeIntentGallonsToLitres,
    intents_conversion.aquariumVolumeIntentLitresToGallons,
    intents_helper.thankYou,
    intents_tank.tankObservation,
    intents_built_in.fallbackHandler,
    intents_unhandled.unhandledIntent,
  )
  .addErrorHandlers(error_handler.errorHandler)
  .withTableName('Tank-Mate')
  .withAutoCreateTable(true)
  .lambda();

错误看起来像这样:

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.<anonymous> (/var/task/index.js:16:17)
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)

...在我看来,这似乎是在抱怨index.js require行。

0 个答案:

没有答案