Open hydevip opened 2 months ago
GPT answer : The issue you're encountering with the double C: in the path is likely due to the handling of URL paths and file paths in a cross-platform Node.js environment. Specifically, new URL(import.meta.url).pathname can produce paths prefixed with a forward slash, which can lead to incorrect path concatenations when used with functions like join from the path module.
Here's a breakdown of why this happens and how to fix it:
Why This Happens URL Pathname: new URL(import.meta.url).pathname returns a pathname that starts with a / on Windows. For example, /C:/Users/... which is valid in URL contexts but not in file system paths. Path Join: The path.join method expects clean file paths. When you join a path that starts with /C:/, it can result in \C:... which then resolves incorrectly to C:\C:....
replacing above function (the one mentioned in screenshot by OP) with below code fixed for me. Be cautious - This code was given by ChatGPT, I am not liable for anything.
async function emptyProfileFolder() {
debug('get emptyProfileFolder');
// Get the current directory path
let currentDir = dirname(new URL(import.meta.url).pathname);
// Handle Windows paths
if (process.platform === 'win32') {
currentDir = currentDir.substring(1).replace(/\//g, '\\');
}
// Join the path to zero_profile.zip
const zeroProfilePath = join(currentDir, '..', 'zero_profile.zip');
// Read the profile file
const profile = await readFile(zeroProfilePath);
debug('emptyProfileFolder LENGTH ::', profile.length);
return profile;
}
Has your problem been resolved?
OS: Win Server 2019 standard Node js v: 20.13.1 Gologin v: 2.0.30
Can't initiate a GoLogin instance on win due to wrong path ' C:\C:\Users\' in
gologin.js file
line 248emptyProfileFolder
methodThe
new GoLogin(...)
will throw this error:It looks like the issue is in the gologin.js file line 248
emptyProfileFolder
method