0

I have been working on migrating a project from Heroku to AWS. I have been able to successfully upload the project onto AWS without any errors, however the applications health is listed as 'Degraded'. I have been reviewing my application logs and believe the issue has something to do with me writing the code on a Mac and then Elastic Beanstalk using a Linux AMI.

"invalid ELF header" when using the nodejs "ref" module on AWS Lambda

However, this post only diagnoses the issue. There is no solution provided. I am aware that there is an architectural mismatch when moving the code from Mac to Linux. I am looking for a solution to that problem.

Here are the error messages in my applications logs:

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
tdammon
  • 599
  • 1
  • 7
  • 26
  • 1
    Are you creating the Beanstalk package on your Mac? Ultimately you've got an architecture mismatch in a native library. If you compiled that native library on your Mac it won't work on the Linux environment of Elastic Beanstalk. – stdunbar Apr 16 '19 at 15:19
  • Possible duplicate of ["invalid ELF header" when using the nodejs "ref" module on AWS Lambda](https://stackoverflow.com/questions/29994411/invalid-elf-header-when-using-the-nodejs-ref-module-on-aws-lambda) – stdunbar Apr 16 '19 at 15:35
  • That is the post I referenced already. This is not a duplicate as no solution is provided. I understand that the issue is with a mismatched architecture. I am asking what can be done to solve that problem – tdammon Apr 16 '19 at 15:38
  • You'll need to build the package in a Linux environment. MacOS does a pretty good job of running something like [VirtualBox](https://www.virtualbox.org/) - you could create a Linux VM to do your build. – stdunbar Apr 16 '19 at 16:01
  • Possible duplicate of [AWS Elastic Beanstalk invalid binary packages](https://stackoverflow.com/questions/55814769/aws-elastic-beanstalk-invalid-binary-packages) – ChrisGPT was on strike Apr 23 '19 at 16:18

0 Answers0