speedDeveloper speedDeveloper - 28 days ago 24
Node.js Question

Google Cloud not working on Node.js

Hey thanks for helping me out.
I install google-cloud with npm, just like:

npm install --save google-cloud


then I implement in my code like that:

var gcloud = require('google-cloud')({
projectId: "czernitzki-148120",
keyFilename: './service.json'
});


I created a key on a new Service Account that has
Owner
access rights and put the file in service.json.
service.json
is in the same directory as the file that has the code above. After I start the application, it blows up when it reaches the code from above

Error in ./~/google-cloud/~/protobufjs/dist/ProtoBuf.js
Module not found: [CaseSensitivePathsPlugin] `C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\ByteBuffer\dist\ByteBufferAB.js` does not match the corresponding path on disk `bytebuffer`.

@ ./~/google-cloud/~/protobufjs/dist/ProtoBuf.js 25:8-39

Error in ./~/google-cloud/~/bytebuffer/dist/ByteBufferAB.js
Module not found: [CaseSensitivePathsPlugin] `C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\Long\dist\Long.js` does not match the corresponding path on disk `long`.

@ ./~/google-cloud/~/bytebuffer/dist/ByteBufferAB.js 26:8-33

Error in ./~/google-cloud/~/JSONStream/index.js
Module parse failed: C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\JSONStream\index.js Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '#' (1:0)
@ ./~/google-cloud/~/@google-cloud/prediction/src/model.js 25:17-38

Error in ./~/google-cloud/~/osenv/osenv.js
Module not found: 'child_process' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\osenv

@ ./~/google-cloud/~/osenv/osenv.js 3:11-35

Error in ./~/google-cloud/~/uid-number/uid-number.js
Module not found: 'child_process' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\uid-number

@ ./~/google-cloud/~/uid-number/uid-number.js 9:20-44

Error in ./~/google-cloud/~/node-pre-gyp/lib/info.js
Module not found: 'aws-sdk' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\node-pre-gyp\lib

@ ./~/google-cloud/~/node-pre-gyp/lib/info.js 14:14-32

Error in ./~/google-cloud/~/node-pre-gyp/lib/publish.js
Module not found: 'aws-sdk' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\node-pre-gyp\lib

@ ./~/google-cloud/~/node-pre-gyp/lib/publish.js 17:14-32

Error in ./~/google-cloud/~/node-pre-gyp/lib/testbinary.js
Module not found: 'child_process' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\node-pre-gyp\lib

@ ./~/google-cloud/~/node-pre-gyp/lib/testbinary.js 10:9-33

Error in ./~/google-cloud/~/node-pre-gyp/lib/unpublish.js
Module not found: 'aws-sdk' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\node-pre-gyp\lib

@ ./~/google-cloud/~/node-pre-gyp/lib/unpublish.js 15:14-32

Error in ./~/google-cloud/~/node-pre-gyp/lib/util/compile.js
Module not found: 'child_process' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\node-pre-gyp\lib\util

@ ./~/google-cloud/~/node-pre-gyp/lib/util/compile.js 9:9-33

Error in ./~/google-cloud/~/google-auth-library/lib/auth/googleauth.js
Module not found: 'child_process' in C:\Users\phili\Documents\GitHub\venos\node_modules\google-cloud\node_modules\google-auth-library\lib\auth

@ ./~/google-cloud/~/google-auth-library/lib/auth/googleauth.js 21:11-35


I am using React with
create-react-app
. I've tested it on Windows and the Google Compute Engine. It didn't work on both.

I followed the guide from https://github.com/GoogleCloudPlatform/google-cloud-node and https://googlecloudplatform.github.io/google-cloud-node/#/docs/storage/0.3.0/storage.

How can I solve this issue?

Answer

google-cloud is a back-end module, and should be used with Node.js, not the front-end.

As mentioned by the comments on this similar question, use Google's front-end api client.