googleapis / nodejs-logging-winston

Node.js client integration between Stackdriver Logging and Winston.
https://cloud.google.com/logging/
Apache License 2.0
105 stars 50 forks source link

@google-cloud/logging-winston (intermediate value).GoogleAuth is not a constructor (vuejs) #789

Closed patrickchho closed 3 days ago

patrickchho commented 1 year ago

I am trying to add @google-cloud/logging-winston to my VueJS project. I followed these https://www.npmjs.com/package/@google-cloud/logging-winston and https://cloud.google.com/logging/docs/samples/logging-winston-quickstart very closely.

I am getting:

TypeError: (intermediate value) (intermediate value) (intermediate value).GoogleAuth is not a constructor
     at new Logging(index.js ? 221c: 137: 1)
     at new LoggingCommon(common.js ? bc26 : 94: 1)
     at new LoggingWinston(index.js ? 1856 : 113: 1)

Here's my code:

const winston = require('winston');

const {LoggingWinston} = require('@google-cloud/logging-winston');

// error here
const gcloudWinston = new LoggingWinston();

I traced the flow of code from new LoggingWinston() --> new LoggingCommon() --> new Logging() and found this line from the @google-cloud/logging library:

this.auth = new (gaxInstance !== null && gaxInstance !== void 0 ? gaxInstance : gax).GoogleAuth(options_);

Screen Shot 2023-03-19 at 11 27 51 PM copy

Question: How do I get new LoggingWinston() to work for my project?

PS: My dependencies are up-to-date:


  "dependencies": {
    "@google-cloud/logging-winston": "^5.3.0",
    "google-gax": "^3.5.8",
    "googleapis": "^113.0.0",
    "node": "^18.15.0",
    "node-polyfill-webpack-plugin": "^2.0.1",
    "vue": "^2.7.14",
...
  },
cindy-peng commented 8 months ago

Hi @patrickchho, you will need to set up authentications correctly for logging: https://cloud.google.com/docs/authentication/provide-credentials-adc

Could you share more details about the authentication set up in your application?

cindy-peng commented 3 days ago

Closing issue for now as more details are needed for investigation. Please feel free to re-open this issue if you are still running into this. Thank you!