paulirish / pwmetrics

Progressive web metrics at your fingertipz
Apache License 2.0
1.25k stars 74 forks source link

Error while trying to retrieve access token, ENOENT: no such file or directory, mkdir '\Users\my\.credentials\' #223

Open rubyzhao opened 4 years ago

rubyzhao commented 4 years ago

Config / CLI options

pwmetrics --config=pwmetrics-config.js

Errors

Error while trying to retrieve access token, ENOENT: no such file or directory, mkdir '\Users\my.credentials\'

Error while trying to retrieve access token, invalid_grant at GoogleOauth.getNewToken

Solution

After digging out in google-oauth.js, change the line as below:

//this.tokenDir = path.join((process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE), '/.credentials/'); // Original 
this.tokenDir = path.join((process.env.USERPROFILE || process.env.HOME || process.env.HOMEPATH), '/.credentials/');

Reason: tokenDir in the original line is equal to \Users\username\.credentials\ tokenDir in the new line is equal to C:\Users\username\.credentials\ , which is the right for Windows.

Environment

  1. pwmetrics version: 4.2.2
  2. Chrome version: Version 78.0.3904.97 (Official Build) (64-bit)
  3. OS version: Win10X64 1803