Skip to content

path.replace is not a function #1445

Description

@commit-master

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!

Activity

  1. stephenplusplus commented on Jul 22, 2016

    @stephenplusplus
    Contributor

    What is the value of key?

  2. commit-master commented on Jul 22, 2016

    @commit-master
    ContributorAuthor

    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.
    
  3. stephenplusplus commented on Jul 22, 2016

    @stephenplusplus
    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.

  4. commit-master commented on Jul 22, 2016

    @commit-master
    ContributorAuthor

    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 ! 👍

  5. stephenplusplus commented on Jul 22, 2016

    @stephenplusplus
    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

Metadata

Metadata

Labels

coretype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions