本文介绍了“无效的 ELF 标头"使用 nodejs“ref"时AWS Lambda 上的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将 zip 上传到 AWS Lambda,其中包含ref"(https://www.npmjs.com/package/ref),这是验证 iOS Game Center 身份验证令牌所必需的(如何从 3rd 方 node.js 服务器验证 Game Center 用户).

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).

不幸的是,调用它会导致无效的 ELF 标头"错误,

Unfortunately invoking it results in the "invalid ELF header" error,

{
  "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)"
  ]
}

这是在运行 Yosemite 的 64 位 Macbook Pro 上开发的,在本地运行代码没有问题.谷歌搜索无效的 ELF 标头"几乎没有了解相关结果,我真的不知道从哪里开始.我最好在 node.js 区域询问这个问题,还是这是相关区域,因为它可能是平台的问题?

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?

推荐答案

当您在一种架构上构建,然后尝试在不同的架构(或在某些情况下为平台)上使用相同的构建插件时,就会发生这种情况.

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).

根据此页面,可能必须针对亚马逊编译插件EC2 上的 Linux 映像,以便编译后的插件可在其 Lambda 服务上使用.

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.

这篇关于“无效的 ELF 标头"使用 nodejs“ref"时AWS Lambda 上的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 06:41