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 .
我正在开发一个需要我使用gcloud nodejs模块的项目。我正在使用节点应用在本地测试此项目,并使用gcloud预览应用运行app.yaml在gcloud上本地测试。当我在我的文件中有以下代码时,项目使用节点应用程序运行但不使用gcloud使用gcloud预览应用程序运行app.yaml - 我收到无效的ELF标头错误。
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?
我相信该项目不会使用gcloud命令运行,因为它与我在项目中使用gcloud模块有关。如果我从我的文件中删除该代码,该项目使用gcloud命令运行正常。我该怎么做才能解决这个问题?
I was able to get the error by using a try-catch
我通过使用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 个解决方案
#1
2
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.
我能够通过删除node_modules目录然后部署项目来解决此问题。问题与OS X编译库无法在Linux机器上运行有关。因此,它需要在Linux机器上进行全新安装 - 删除node_modules会直接强制它在linux机器上进行全新安装。
#1
2
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.
我能够通过删除node_modules目录然后部署项目来解决此问题。问题与OS X编译库无法在Linux机器上运行有关。因此,它需要在Linux机器上进行全新安装 - 删除node_modules会直接强制它在linux机器上进行全新安装。