问题
I have a Node.js application which runs correctly on localhost, but not in the Compute Engine VM. Here is a snippet:
try {
gcloud = require('gcloud');
var storage = gcloud.storage({ projectId: 'project-id' });
var bucket = storage.bucket('my-bucket');
bucket.file(src_file).createReadStream().pipe(fs.createWriteStream(src_file));
} catch (e) {
e = 'Error loading required classes for gcloud: '+gcloud+ ': '+e
console.log(e)
res.status(200).send(e);
}
When I run this code
undefined: Error: /app/node_modules/gcloud/node_modules/hash-stream-validation/node_modules/sse4_crc32/build/Release/sse4_crc32.node: invalid ELF header
It looks like I'm not able to import the gcloud classes, but I can't understand why it works in localhost but not in the GCE server??
回答1:
Invalid ELF sounds like you uploaded from localhost or compiled in a different environment. Those deps need to be compiled/configured on the Google server. Did you follow these instructions?
来源:https://stackoverflow.com/questions/32679728/unable-to-run-application-in-google-compute-engine-vm