Skip to content

Conversation

Kaibu
Copy link

@Kaibu Kaibu commented Apr 6, 2024

path.join will throw an error if undefined.
Even though platform is win32, process.env.windir may be undefined.

In this case the library should fallback to the path reg, one could add more fallback options like %systemroot%.
But falling back to path is definitly better than failing.

I came upon this issue using winreg in electron 29.1.1

TypeError: The "path" argument must be of type string. Received undefined at __node_internal_captureLargerStackTrace (node:internal/errors:497:5) at new NodeError (node:internal/errors:406:5) at validateString (node:internal/validators:162:11) at Object.join (node:path:433:7) at xs (index-2b4f9e2c.js:51:251) at ht.values (index-2b4f9e2c.js:51:1965) at ht.keyExists (index-2b4f9e2c.js:54:2663)

function xs() { return process.platform === "win32" ? a5.join({}.windir, "system32", "reg.exe") : "REG" }

path.join will throw an error if undefined, even though platform is win32, process.env.windir may be undefined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant