Wednesday, 7 June 2017

Serverless is failing when trying to initialize google cloud apis in node js

I am using google datastore for nodejs6.10 and it is working fine with serverless offline. But when i deployed and tried to use the functions urls.

I am getting following error:

module initialization error: Error
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> 
(/var/task/node_modules/grpc/src/node/src/grpc_extension.js:38:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)

I have tried installing npm packages and uploaded them but of no use.

Below is snapshot of my serverless provider section:

provider:
 name: aws
 runtime: nodejs6.10
 environment:
   Environment: ${env:Environment}
 region: ${env:AWS_REGION}

This is how i am trying to use datastore:

let datastore = require('@google-cloud/datastore')({
projectId: configFile[process.env.Environment].project,
keyFilename: configFile[process.env.Environment].keyfile
});

Can someone help me with this.



via Tarun Kaushik

No comments:

Post a Comment