AWS Lambda Function is returning “Cannot find module 'index'” yet the handler in the config is set to index

后端 未结 7 1104
青春惊慌失措
青春惊慌失措 2021-01-31 15:51

As my title explains I am getting the following error:

 {
  \"errorMessage\": \"Cannot find module \'index\'\",
  \"errorType\": \"Error\",
  \"stackTrace\": [
          


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 16:48

    Correct Lambda function declaration can look like this:

    var func = function(event, context) {
       ...
    };
    
    exports.handler = func;
    

    You may have other syntax errors that prevent the index.js file from being properly ran. Try running your code locally using another file and using the index.js as your own module.

提交回复
热议问题