我上传并测试AWS Lambda函数时收到此错误: { "errorMessage": "Cannot find module 'elasticsearch'", "errorType": "Error", "stackTrace": [ "Function.Module._load (module.js:276:25)", "Module.require (module.js:353:17)", "require
{ "errorMessage": "Cannot find module 'elasticsearch'", "errorType": "Error", "stackTrace": [ "Function.Module._load (module.js:276:25)", "Module.require (module.js:353:17)", "require (internal/module.js:12:17)", "Object.<anonymous> (/var/task/PublishElasticsearch.js:17:21)", "Module._compile (module.js:409:26)", "Object.Module._extensions..js (module.js:416:10)", "Module.load (module.js:343:32)", "Function.Module._load (module.js:300:12)", "Module.require (module.js:353:17)" ] }
以及需要()s模块的代码行:
var elasticsearch = require('elasticsearch')({ host: config.ElasticHost });
该功能成功运行唯一的问题是需要我的模块.
我在函数目录中运行npm install,我上传的ZIP结构如下:
PublishElasticsearch.zip PublishElasticsearch.js node_modules elasticsearch
有谁知道为什么我会收到这个错误?
你可以在这里尝试这个anwser: aws-lambda Cannot find module看起来像是你可能遇到的同样问题