Alexa Lambda Function “Unable to import module 'index'” when using new required function












0















I'm building an Alexa skill (deploying via CLI), and all has been going well up until needing to make a few Http calls.



I decided to use first axios, then require in order to do so.



When I installed axios using npm, all seemed well. Adding just the "const axios= require('axios');" line caused my lambda function to start complaining about "Unable to import module 'index'" in the Cloudwatch logs, however, and specifically calling out the line in index.js where I make that require statement.



Removed axios, tried require...same deal.



Any thoughts?



Not actually using the packages yet even, it complains on the require line if I uncomment it.



/* 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();


Error looks like this:



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)


...which to me looks like it's complaining about the index.js require line.










share|improve this question









New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

    – Milan Cermak
    Jan 18 at 13:59











  • I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

    – Adam Till
    Jan 18 at 14:31











  • I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

    – Adam Till
    Jan 18 at 14:33
















0















I'm building an Alexa skill (deploying via CLI), and all has been going well up until needing to make a few Http calls.



I decided to use first axios, then require in order to do so.



When I installed axios using npm, all seemed well. Adding just the "const axios= require('axios');" line caused my lambda function to start complaining about "Unable to import module 'index'" in the Cloudwatch logs, however, and specifically calling out the line in index.js where I make that require statement.



Removed axios, tried require...same deal.



Any thoughts?



Not actually using the packages yet even, it complains on the require line if I uncomment it.



/* 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();


Error looks like this:



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)


...which to me looks like it's complaining about the index.js require line.










share|improve this question









New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

    – Milan Cermak
    Jan 18 at 13:59











  • I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

    – Adam Till
    Jan 18 at 14:31











  • I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

    – Adam Till
    Jan 18 at 14:33














0












0








0








I'm building an Alexa skill (deploying via CLI), and all has been going well up until needing to make a few Http calls.



I decided to use first axios, then require in order to do so.



When I installed axios using npm, all seemed well. Adding just the "const axios= require('axios');" line caused my lambda function to start complaining about "Unable to import module 'index'" in the Cloudwatch logs, however, and specifically calling out the line in index.js where I make that require statement.



Removed axios, tried require...same deal.



Any thoughts?



Not actually using the packages yet even, it complains on the require line if I uncomment it.



/* 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();


Error looks like this:



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)


...which to me looks like it's complaining about the index.js require line.










share|improve this question









New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm building an Alexa skill (deploying via CLI), and all has been going well up until needing to make a few Http calls.



I decided to use first axios, then require in order to do so.



When I installed axios using npm, all seemed well. Adding just the "const axios= require('axios');" line caused my lambda function to start complaining about "Unable to import module 'index'" in the Cloudwatch logs, however, and specifically calling out the line in index.js where I make that require statement.



Removed axios, tried require...same deal.



Any thoughts?



Not actually using the packages yet even, it complains on the require line if I uncomment it.



/* 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();


Error looks like this:



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)


...which to me looks like it's complaining about the index.js require line.







node.js requirejs axios alexa alexa-skills-kit






share|improve this question









New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Jan 18 at 14:37







Adam Till













New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Jan 18 at 13:51









Adam TillAdam Till

13




13




New contributor




Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Adam Till is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

    – Milan Cermak
    Jan 18 at 13:59











  • I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

    – Adam Till
    Jan 18 at 14:31











  • I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

    – Adam Till
    Jan 18 at 14:33



















  • Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

    – Milan Cermak
    Jan 18 at 13:59











  • I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

    – Adam Till
    Jan 18 at 14:31











  • I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

    – Adam Till
    Jan 18 at 14:33

















Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

– Milan Cermak
Jan 18 at 13:59





Can you share the code of your index module? It might just be a syntax error in some other place, unrelated to the axios module.

– Milan Cermak
Jan 18 at 13:59













I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

– Adam Till
Jan 18 at 14:31





I've added the code above. I would prefer to eventually move the require line into the globals.js file, but it barfs there too.

– Adam Till
Jan 18 at 14:31













I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

– Adam Till
Jan 18 at 14:33





I can see the packages in my node modules just fine, and it doesn't complain about the ask-sdk which comes in the same way

– Adam Till
Jan 18 at 14:33












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Adam Till is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54255398%2falexa-lambda-function-unable-to-import-module-index-when-using-new-required%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








Adam Till is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Adam Till is a new contributor. Be nice, and check out our Code of Conduct.













Adam Till is a new contributor. Be nice, and check out our Code of Conduct.












Adam Till is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54255398%2falexa-lambda-function-unable-to-import-module-index-when-using-new-required%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Callistus III

Plistias Cous

Index Sanctorum