Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path.replace is not a function #1445

Closed
commit-master opened this issue Jul 22, 2016 · 5 comments
Closed

path.replace is not a function #1445

commit-master opened this issue Jul 22, 2016 · 5 comments
Assignees
Labels
core type: question Request for information or clarification. Not an issue.

Comments

@commit-master
Copy link
Contributor

commit-master commented Jul 22, 2016

Hey guys,

So i'm having the same issue as #1389 and i cannot identify why. Here are the logs of the error :

var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
                 ^

TypeError: path.replace is not a function
    at Mime.lookup (/Users/devOps/Desktop/_devOps/once-rest/node_modules/mime/mime.js:70:18)
    at GoogleToken.getToken (/Users/devOps/Desktop/_devOps/once-rest/node_modules/gtoken/lib/index.js:55:33)
    at /Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auth-library/lib/auth/jwtclient.js:137:21
    at JWT._createGToken (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auth-library/lib/auth/jwtclient.js:225:12)
    at JWT.refreshToken_ (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auth-library/lib/auth/jwtclient.js:133:15)
    at JWT.OAuth2Client.refreshAccessToken (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auth-library/lib/auth/oauth2client.js:203:8)
    at JWT.OAuth2Client.getAccessToken (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auth-library/lib/auth/oauth2client.js:237:10)
    at /Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auto-auth/index.js:118:12
    at addScope (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auto-auth/index.js:74:5)
    at Auth.getAuthClient (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auto-auth/index.js:49:5)
    at Auth.getToken (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auto-auth/index.js:112:8)
    at Auth.authorizeRequest (/Users/devOps/Desktop/_devOps/once-rest/node_modules/google-auto-auth/index.js:16:8)
    at Storage.makeAuthenticatedRequest (/Users/devOps/Desktop/_devOps/once-rest/node_modules/gcloud/lib/common/util.js:371:18)
    at Storage.Service.request (/Users/devOps/Desktop/_devOps/once-rest/node_modules/gcloud/lib/common/service.js:117:15)
    at Storage.getBuckets (/Users/devOps/Desktop/_devOps/once-rest/node_modules/gcloud/lib/storage/index.js:399:8)
    at makeRequest (/Users/devOps/Desktop/_devOps/once-rest/node_modules/gcloud/lib/common/stream-router.js:202:5)

Environment details

  • OS: OS X El Capitan
  • Node.js version: 6.2.1
  • npm version: 3.9.3
  • gcloud-node version: 0.37.0

Steps to reproduce

var gcloud = require('gcloud')({
  keyFilename: key,
  projectId: 'xxxxx-projectId'
});

var gcs = gcloud.storage();
var bucket = gcs.bucket('xxxxxx-bucket');
gcs.getBuckets(function(err, buckets) {
  if (!err) {
    // buckets is an array of Bucket objects.
    console.log(buckets);
  }
});

Thanks!

@stephenplusplus
Copy link
Contributor

What is the value of key?

@commit-master
Copy link
Contributor Author

commit-master commented Jul 22, 2016

Its a JSON file downloaded from the Google Dev Console that has project_id, private_key_id, private_key, client_email, client_id, auth_uri

Also, if is change keyFilename by keyFile the error is gone but I get another one :

Error: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information.

@stephenplusplus
Copy link
Contributor

Is it the object itself, or a string path to the file? If you want to provide an object, use credentials instead of keyFilename. keyFilename expects a string path to the JSON file, i.e. /Users/stephen/dev/keyfile.json.

@commit-master
Copy link
Contributor Author

Oh alright it's working now, using credentials. I suggest you add it to the documentation, it's pretty confusing (at least for me)

Thanks again ! 👍

@stephenplusplus
Copy link
Contributor

Woo! I'll update the other issue as well in case that was the problem over there.

Here's a link to the relevant docs page: https://googlecloudplatform.github.io/gcloud-node/#/docs/v0.37.0/gcloud -- a PR would be awesome if you find a way we can explain better. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants