Question
Script using uxp module crashes in Developer Tool, but not without
The following script runs fine when launched from the Scripts Panel, but when run in the UXP Developer Tool, it gives this error message: "Cannot read properties of undefined (reading 'on')".
const versionInfo = await getVersion();
alert(versionInfo);
function alert(msg) {
const theDialog = app.dialogs.add(),
col = theDialog.dialogColumns.add();
msg.split('\n').forEach(line => {
const colText = col.staticTexts.add();
colText.staticLabel = line;
});
theDialog.canCancel = false;
theDialog.show();
theDialog.destroy();
}
async function getVersion() {
const versions = require('uxp').versions;
const host = require('uxp').host;
return `Host: ${host.name} ${host.version} ${host.uiLocale}\nUXP: ${versions.uxp}`;
}Stepping through, require('uxp').host is the offending command.
Using InDesign 18.3 with UXP 6.5.0
