rebellion1969
rebellion1969

Reputation: 1

Assistance with "the path argument must be of type string"

I am attempting (without any actual good knowledge of JS) to change location a program looks in for a "history" folder for a 2nd program. I've tried one method which failed miserably. Upon looking a little closer this JS script is looking at the shell folders in the registry for the "Personal" folder location (ie The Documents folder). I realised in order to get the app to work how I want it to, I would need to add a registry value (string) to get it pointing in the right direction. Firstly I created a STRING value in the Shell Folders (ie key: '\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders') called "VirtualDJ" >> This points to "C:"user"\AppData\Local". I then intended to have this then locate a folder within this location for the app to do its magic. This program basically looks in this location for a file called "tracklist.txt" (which is stored in \VirtualDJ\History\tracklist.txt) which is used by a 2nd program that lists tracks played on a program called VirtualDJ. The program can then display current and historical track data in a format I can display on a browser source for OBS.

It must be noted that I obviously did not create this program. I believe the author of this script no longer maintains it (via github - erikrichardlarson >> Unbox) and it DID used to work (intermittently) in a previous version of VirtualDJ, solely because program data USED to be stored in the Documents folder. With this latest update the location of this data has changed to a subdirectory within the AppData/Local folder. Hence MY attempt at trying to make this change myself in order to get the program working again.

My stumbling block is the fact that the program is returning a "path argument must be of type string" error. The full error is:

Uncaught Exception: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined. at ValidateString (internal/validators.js:112:11) at Object.join (path.js:375:7) at PlayHistory.getRecentTracks (C:\Users\lbg32\Desktop\unbox-windows\resources\app\src\index.js:520:41) at PlayHistory.persistHistory (C:\Users\lbg32\Desktop\unbox-windows\resources\app\src\index.js:698:10) at Timeout._onTimeout (C:\Users\lbg32\Desktop\unbox-windows\resources\app\src\index.js:752:28) at listOnTimeout (internal/timers.js:531:17) at processTimers (internal/timers.js:475:7)

I added a string Value at key: '\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' called "VDJ".

From here in the script (index.js) I changed the associated key to reflect the string value I added to the windows registry (Shell Folders)

the following are lines 211 to 223 of index.js

   var myDocFolder = regKey.values(function(err, items) {
            for (var i in items) {
                if (items[i].name === 'VDJ') { 
                    deferred.resolve(items[i].value);
                }
            }
        });
        deferred.promise.nodeify(callback);
        return deferred.promise;
    }
    var __this = this;
    getUserDoc().then(function(result) {
        __this.windowsHome = result;

On line 520 the specific path for the file (tracklist.txt) is referenced:

 if (_this.mode == 'virtualdj') {
      var tracks = fs.readFileSync(path.join(this.windowsHome, 'VirtualDJ\\History\\tracklist.txt')).toString().split('\n')
      tracks.pop()
      var lastLine = tracks.pop()
      var artistTrack = lastLine.split(' : ').pop().trim()
      var artist = artistTrack.split(' - ')[0]
      var track = artistTrack.split(' - ')[1]
      var time = lastLine.split(' : ')[0];
      var d = new Date();
      var today_abs = new Date(d.toLocaleString('en-US', { timeZone: 'America/Los_Angeles' })); 
      today_abs.setHours(time.split(":")[0]);
      today_abs.setMinutes(time.split(":")[1]);
      today_abs.setSeconds(0);

What was I expecting? TBF I werent sure if my fabled attempt at changing the code for myself would work (and lets be honest! Its like putting a cat in a sealed box and hoping for the best!). The stumbling block IS the fact that its saying that the key I added to the registry is an invalid string. How I need to correct that so the program actually works as I want it to is the hurdle in my path.

Upvotes: 0

Views: 161

Answers (0)

Related Questions