AWS Elastic Beanstalk无效的二进制软件包 [英] AWS Elastic Beanstalk invalid binary packages

查看:62
本文介绍了AWS Elastic Beanstalk无效的二进制软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将项目从Heroku迁移到AWS.部署后,我一直收到错误消息:无效的ELF标头".使用AWS Lambda时,我发现有类似问题的帖子,但是我不明白为什么我在Elastic Beanstalk中的二进制软件包会遇到问题.

I am working on migrating a project from Heroku to AWS. I keep getting an error after deployment saying: 'invalid ELF header'. I have found posts with similar issues when using AWS Lambda, but I do not understand why I would have an issue with binary packages in Elastic Beanstalk.

Elastic Beanstalk不能提供一个配置好的环境来运行我的类似于Docker的代码吗?我觉得这个问题必须更加复杂,因为在Elastic Beanstalk中找不到其他人遇到这个问题.

Doesn't Elastic Beanstalk provide a configured environment to run my code similar to Docker? I feel like this problem must be more complex as I cannot find anyone else with this issue in Elastic Beanstalk.

这是我得到的确切错误:

Here is the exact error I am getting:

Error: /var/app/current/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (internal/modules/cjs/loader.js:730:18)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/var/app/current/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! beer@0.1.0 start: `node server/server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the beer@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/.npm/_logs/2019-04-15T00_54_06_983Z-debug.log

我在Mac上工作,我的代码包含用React,node.js和SQL编写的客户端和服务器代码.我正在通过包含多个文件夹(包括node_modules/)的ZIP文件上传代码.

I am working on a Mac, my code contains both client and server code written in React, node.js, and SQL. I am uploading my code via a ZIP file containing multiple folders, including node_modules/.

推荐答案

某些库对构建它们的操作系统和/或CPU体系结构很敏感.对于以低级语言或链接到系统库的模块实现的情况尤其如此.在这种情况下,您似乎正在使用 bcrypt ,即

Some libraries are sensitive to the operating system and / or CPU architecture on which they are built. This is especially true of modules implemented in low-level languages, or that link to system libraries. In this case, you appear to be using bcrypt which is largely written in C++.

这是您上传到Elastic Beanstalk的zip文件不应包含您的node_modules/文件夹(或Git忽略的其他任何文件)的原因之一.创建要上传到Elastic Beanstalk的zip的最简单方法是

This is one reason that the zip file you upload to Elastic Beanstalk shouldn't include your node_modules/ folder (or anything else that Git is ignoring). The easiest way to create a zip for uploading to Elastic Beanstalk is probably to use git archive:

 git archive -v -o myapp.zip --format=zip HEAD

这将尊重您的无视,而手动压缩将包含它们.

This will respect your ignores, whereas manually zipping will include them.

您的归档文件的根目录中应包含package.jsonpackage-lock.json. Elastic Beanstalk 将从这些文件中安装其自己的node_modules/ (如果存在).这应该确保所有库与其操作系统兼容.

Your archive should include package.json and package-lock.json in its root. Elastic Beanstalk will install its own node_modules/ from these files if they are present. This should ensure that all libraries are compatible with its operating system.

这篇关于AWS Elastic Beanstalk无效的二进制软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆