We should replace process.execPath with something like common.execPath. While process.execPath does not always point to NodeJS (like if it's running within electron), common.execPath ideally should, allowing us to reliably use the within exec and other utilities.
At startup, we can set common.execPath to:
process.execPath if not within electron
- otherwise use
which('node') if it returns something
- otherwise use
which('nodejs') if it returns something
- otherwise we can leave it null and fail early whenever we try to use it (like in
shell.exec), displaying a descriptive error message (at least an improvement over the current cryptic error message).
Also, this would allow electron users to manually override common.execPath with the hardcoded path of their NodeJS binary if the above approach fails. While not ideal, that should at least be a suitable workaround until we can figure out a solid way to reliably get a path to the current node instance.
Linking this to #480
We should replace
process.execPathwith something likecommon.execPath. Whileprocess.execPathdoes not always point to NodeJS (like if it's running within electron),common.execPathideally should, allowing us to reliably use the withinexecand other utilities.At startup, we can set
common.execPathto:process.execPathif not within electronwhich('node')if it returns somethingwhich('nodejs')if it returns somethingshell.exec), displaying a descriptive error message (at least an improvement over the current cryptic error message).Also, this would allow electron users to manually override
common.execPathwith the hardcoded path of their NodeJS binary if the above approach fails. While not ideal, that should at least be a suitable workaround until we can figure out a solid way to reliably get a path to the current node instance.Linking this to #480