在 AWS Lambda 上使用 nodejs“ref”模块时出现“无效 ELF 标头”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29994411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"invalid ELF header" when using the nodejs "ref" module on AWS Lambda
提问by seaders
I've just uploaded a zip to AWS Lambda which included the "ref" (https://www.npmjs.com/package/ref), which is needed to validate an iOS Game Center authentication token (How to authenticate Game Center User from 3rd party node.js server).
我刚刚上传了一个 zip 到 AWS Lambda,其中包含“ref”(https://www.npmjs.com/package/ref),这是验证 iOS Game Center 身份验证令牌所需的(如何对 Game Center 用户进行身份验证来自第 3 方 node.js 服务器)。
Unfortunately invoking it results in the "invalid ELF header" error,
不幸的是,调用它会导致“无效的 ELF 标头”错误,
{
"errorMessage": "/var/task/node_modules/ref/build/Release/binding.node: invalid ELF header",
"errorType": "Error",
"stackTrace": [
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)",
"bindings (/var/task/node_modules/ref/node_modules/bindings/bindings.js:76:44)",
"Object.<anonymous> (/var/task/node_modules/ref/lib/ref.js:5:47)",
"Module._compile (module.js:456:26)",
"Object.Module._extensions..js (module.js:474:10)",
"Module.load (module.js:356:32)",
"Function.Module._load (module.js:312:12)"
]
}
This has been developed on a 64bit Macbook Pro running Yosemite which has no problem running the code locally. Googling around for "invalid ELF header" has yielded little to know relevant results and I'm really not sure where to go from here. Would I be better asking this in a node.js area, or is this the relevant area, because it might be an issue with the platform?
这是在运行 Yosemite 的 64 位 Macbook Pro 上开发的,在本地运行代码没有问题。谷歌搜索“无效的 ELF 标头”几乎没有了解相关结果,我真的不知道从哪里开始。我会更好地在 node.js 区域询问这个问题,还是这是相关区域,因为它可能是平台的问题?
回答by mscdex
This happens when you build on one architecture and then attempt to use the same built addon on a different architecture (or platform in some cases).
当您在一种架构上构建,然后尝试在不同的架构(或某些情况下的平台)上使用相同的构建插件时,就会发生这种情况。
According to this page, addons may have to be compiled against an Amazon Linux image on EC2 in order for the compiled addons to be usable on their Lambda service.
根据此页面,可能必须针对 EC2 上的 Amazon Linux 映像编译插件,以便编译后的插件可用于其 Lambda 服务。
回答by Matt Fletcher
This doesn't apply exactly to your question, but in case anyone stumbles across this when using AWS Elastic Beanstalk, it could be a result of uploading the node_modules/directory along with everything else, so you need to force it to ignore the file.
这并不完全适用于您的问题,但万一有人在使用 AWS Elastic Beanstalk 时偶然发现了这一点,这可能是上传node_modules/目录以及其他所有内容的结果,因此您需要强制它忽略该文件。
.ebignore
.ebignore
node_modules/

