NodeJs Google Compute Engine Invalid ELF Header when using 'gcloud' module

青春壹個敷衍的年華 提交于 2020-02-05 07:53:05

问题


I am working on a project that requires me to use the gcloud nodejs module. I am testing this project locally using node app and locally on gcloud using gcloud preview app run app.yaml . When I have the following code in my file the project runs with node app but doesn't run with gcloud using gcloud preview app run app.yaml - I get the an invalid ELF Header error .

var gcloud = require('gcloud');

I believe the project doesn't run with the gcloud command because it has something to do with me using the gcloud module in my project. If I remove that code from my file, the project runs just fine with the gcloud command. What should I do to fix this?

I was able to get the error by using a try-catch

try {
   var gcloud = require('gcloud');

}  catch (e) {
   e = 'Error loading required classes for gcloud: '+gcloud+ ':  '+e
   console.log(e)
   res.status(200).send(e);
}

The Error:

Error loading required classes for gcloud: undefined: Error:
/app/node_modules/gcloud/node_modules/hash-stream-
validation/node_modules/sse4_crc32/build/Release/sse4_crc32.node: invalid ELF header

回答1:


I was able to fix this problem by removing the node_modules directory and then deploying the project. The problem had to do with an OS X compiled library not working on a Linux machine. Therefore it need a fresh install on the Linux machine - removing the node_modules directly forces it to fresh install on the linux machine.



来源:https://stackoverflow.com/questions/32618976/nodejs-google-compute-engine-invalid-elf-header-when-using-gcloud-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!