One of my node modules (web3) has a dependency on scrypt. When I deploy and invoke it, I get an error:
{
"errorMessage": "/var/task/node_modules/scrypt/build/Release/scrypt.node: invalid ELF header",
"errorType": "Error",
"stackTrace": [
"Object.Module._extensions..node (module.js:597:18)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/node_modules/scrypt/index.js:3:20)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)"
]
}
I did some research and it looks like it’s due to the fact that I npm installed it on a macOS machine (my development machine) and deployed it to Lambda, which is Unix-based. More info here:
Is there a way around this issue? I could try to build it on Linux and copy-paste the module files into my dev environment, but then my local environment would not work properly.