Google Cloud not working on Node.js - 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?

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.

You need to do npm install for the modules that are not found,like the following :
npm install aws-sdk
For the first two errors regarding CaseSensitivePathsPlugin,you can find the solution at Case Sensitive Paths - Webpack Plugin

Related

How to solve Module not found: Error: Can't resolve 'fs' without overriding webpack config

I have a react app and all of a sudden I got the below errors while I run npm start:
ERROR in ./node_modules/sass/sass.dart.js 118:12-25
Module not found: Error: Can't resolve 'fs' in .......
webpack compiled with 1 error and 1 warning
I manage to handle it with adding fallback to webpack.config.js like below:
.....
resolve: {
// This allows you to set a fallback for where webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
// if there are any conflicts. This matches Node resolution mechanism.
// https://github.com/facebook/create-react-app/issues/253
fallback:{
"fs":false
},
}
it solved the problem but I don't want to override webpack.config.js because if I remove my node modules and some one else tries to npm install then he will get the error again.
how can I solve the error without overriding webpack.config.js?

paypal-rest-sdk angular 8 universal error module not found after npm

i just upgraded from angular 5 to angular 8 universal. this is my api.ts file i imported
var paypal = require('paypal-rest-sdk');
and npm i but when i build its saying module not found.
and this is the error message.
ERROR in ./node_modules/paypal-rest-sdk/lib/configure.js
Module not found: Error: Can't resolve '../package' in '/Users/salvadormireles/Downloads/angular-universal-crud-master/node_modules/paypal-rest-sdk/lib'
# ./node_modules/paypal-rest-sdk/lib/configure.js 4:38-59
# ./node_modules/paypal-rest-sdk/lib/paypal-rest-sdk.js
# ./node_modules/paypal-rest-sdk/index.js
# ./routes/users.ts
# ./server.ts

Use worker_threads in combination with node (v11.15.0), webpack and typescript -> module not found

I'm writting a NodeJS application where I want to use worker_threads to get rid of a blocking I/O call _mfrc522.findCard() by a third party module (mfrc522-rpi) which delays the request handling of a WebApi in the same application.
When I try to reference the worker_threads module in my TypeScript file I get the following WebPack error message:
const { Worker } = require('worker_threads');
ERROR in ./core/command-processing/rfid-command-processor.ts
Module not found: Error: Can't resolve 'worker_threads' in '/home/pi/leabox/src/core/command-processing'
# ./core/command-processing/rfid-command-processor.ts 11:19-44
# ./core/leabox-controller.ts
# ./index.ts
But I'm able to execute the following command directly:
node -e "require('worker_threads'); console.log('success');
Output:
success
Node version: 11.15.0
WebPack version: 4.41.2
TypeScript version: 3.6.4
Activating experimental worker support for node.js via the command line before starting the application solved the issue for me:
export NODE_OPTIONS=--experimental-worker
Please check this thread for further information.

Module not found API Moip in Angular 5

What do I need to do to import and use the Moip SDK correctly without error?
I am trying to integrate into my Angular application the Moip API using https://github.com/moip/moip-sdk-node.
When running the code below in my moip-api.service.ts file, an error is occurring.
import moipSdk from 'moip-sdk-node'
const moip = moipSdk({
token: 'your-access-token',
key: 'your-access-key',
production: false
});
In Visual Studio Code:
Try npm install #types/moip-sdk-node if it exists or add a new
declaration (.d.ts) file containing declare module 'moip-sdk-node';
In cmd.exe Running ng serve:
ERROR in ./node_modules/moip-sdk-node/dist/client/api.js Module not
found: Error: Can't resolve '../../package' in
'C:\dev\allclinics\node_modules\moip-sdk-node\dist\client' ERROR in
./node_modules/moip-sdk-node/dist/client/api_assinaturas.js

Webpack Error: Cannot find module "."

I am using the api from musixmatch-sdk and have an error by building my project with webpack.
I am using webpack 2, react, node.
The default import on the musixmatch site is:
var MusixmatchApi = require('../../build/javascript-client/src/index');
But this does't work and getting this error:
ERROR in ./build/javascript-client/src/index.js<br/>
Module not found: Error: Can't resolve 'ApiClient' in '/Users/myname/lyrix/build/javascript-client/src'<br/>
# ./build/javascript-client/src/index.js 28:4-2099<br/>
# ./src/server.js
So I have wrote it with an absolute path like:
const MusixmatchApi = require(path.join(__dirname,'../build/javascript-client/src/index'));
This works in development mode of webpack, but i get this warning:
WARNING in ./src/server.js
33:20-102 Critical dependency: the request of a dependency is an expression
# ./src/server.js
So if I want to build the production project i get the error:
Error: Cannot find module "."<br/>
at /Users/myname/lyrix/src/server-es5.js:1:16712<br/>
at Object.<anonymous> (/Users/myname/lyrix/src/server-es5.js:1:16782)
Can you please help me?

Resources