AWS Lambda: Unable to import module

后端 未结 6 1294
误落风尘
误落风尘 2021-02-05 13:12

please forgive me, I am totally new at Lambda and Node.

I am trying to replicate this git to order a pizza using an AWS IoT button.

My current code is:

<

6条回答
  •  难免孤独
    2021-02-05 13:21

    I had the same issue and got it solved by the following the below steps

    1. dont use the default zip option provided in the finder in mac. use terminal to zip

    cd foldername

    zip -r foldername.zip *

    1. use exports in all your js functions which you want to use in the index.js file.

    Say in Javascript file a.js

    var func = function(){
    
    }
    
    export.func = func ; 
    

    In index.js

    var a = require('a.js')
    exports.handler(event, context, callback){
    
    a.func
    
    }
    

提交回复
热议问题