diff --git a/lib/osinfo.js b/lib/osinfo.js index f6d88a0..e461f4b 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -589,8 +589,7 @@ function versions(callback) { if (_darwin) { // check if any JVM is installed but avoid dialog box that Java needs to be installed exec('/usr/libexec/java_home -V 2>&1', function (error, stdout) { - const output = stdout.toString().toLowerCase(); - if (output.indexOf('no java runtime') === -1) { + if (!error && stdout.toString().toLowerCase().indexOf('no java runtime') === -1) { // now this can be done savely exec('java -version 2>&1', function (error, stdout) { if (!error) {