使用'gcloud'模块时NodeJs Google计算引擎无效的ELF标题 [英] NodeJs Google Compute Engine Invalid ELF Header when using 'gcloud' module

查看:165
本文介绍了使用'gcloud'模块时NodeJs Google计算引擎无效的ELF标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个需要我使用gcloud nodejs模块的项目。我在本地使用节点应用程序和本地gcloud使用 gcloud预览应用程序运行app.yaml 来测试此项目。
当我在我的文件中有以下代码时,该项目运行时使用节点应用程序,但不会使用gcloud使用运行gcloud预览应用程序运行app.yaml - 我得到一个无效的ELF Header 错误。

  var gcloud = require('gcloud'); 

我相信该项目不会使用gcloud命令运行,因为它与我使用我的项目中的gcloud模块。如果我从我的文件中删除该代码,该项目使用gcloud命令运行得很好。我应该怎么做才能解决这个问题?



我能够通过使用try-catch来获取错误

  try {
var gcloud = require('gcloud');
$ b} catch(e){
e ='错误加载所需的gcloud类:'+ gcloud +':'+ e
console.log(e)
res .STATUS(200)。发送(E);

$ / code>

错误:

 加载gcloud所需的类时出错:undefined:错误:
/ app / node_modules / gcloud / node_modules / hash-stream-
验证/ node_modules / sse4_crc32 / build /Release/sse4_crc32.node:invalid ELF header


解决方案

I能够通过删除 node_modules 目录然后部署该项目来解决此问题。这个问题与OS X编译的库不能在Linux机器上工作有关。因此它需要在Linux机器上进行全新安装 - 直接删除node_modules将直接强制它在Linux机器上全新安装。

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

解决方案

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.

这篇关于使用'gcloud'模块时NodeJs Google计算引擎无效的ELF标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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