appsmithorg/appsmith · error · Error
Unable to determine a unique accessor
Error message
Unable to determine a unique accessor
What it means
Thrown as a plain Error('Unable to determine a unique accessor') in installLibrary when, after attempting importScripts and the dynamic-import fallback, the accessors array is still empty. An empty accessors array means the script loaded without exposing any new global on self and no ESM module object was produced, so Appsmith has no name under which to expose the library to bindings.
Source
Thrown at app/client/src/workers/Evaluation/handlers/jsLibrary.ts:222
if (module && typeof module === "object") {
const uniqAccessor = generateUniqueAccessor(
url,
takenAccessors,
takenNamesMap,
);
self[uniqAccessor] = flattenModule(module);
accessors.push(uniqAccessor);
}
} catch (e) {
log.debug(e, `dynamic import failed for ${url}`);
throw new ImportError(url);
}
}
// If no accessors at this point, installation likely failed.
if (accessors.length === 0) {
throw new Error("Unable to determine a unique accessor");
}
// Name of the library is the last accessor. This is totally random and needs fixing.
const name = accessors[accessors.length - 1];
defs["!name"] = `LIB/${name}`;
try {
for (const key of accessors) {
defs[key] = makeTernDefs(self[key]);
}
} catch (e) {
for (const acc of accessors) {
self[acc] = undefined;
}
log.debug(e, `ternDefinitions failed for ${url}`);
throw new TernDefinitionError(
`Failed to generate autocomplete definitions: ${name}`,View on GitHub (pinned to 8cd9021c24)
Solutions
- Use the library's UMD/IIFE bundle that assigns to window/globalThis, or an ESM build that exports its API.
- Point at the documented distribution file (dist/*.min.js or the +esm CDN variant) rather than a source/entry file.
- Verify in a browser console that loading the script actually defines a global (e.g. window._ or window.dayjs).
- If the library is ESM-only, prefer the jsDelivr +esm URL so the dynamic-import path produces a module object.
Example fix
// before https://cdn.jsdelivr.net/npm/some-polyfill/init.js // no global exported // after https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js // defines window._
Defensive patterns
Strategy: validation
Validate before calling
// Before installing, sanity-check that the script defines a global export.
// (Quick client-side check - not a guarantee the worker agrees.)
async function exposesGlobal(url) {
const before = Object.keys(window);
try {
await import(/* webpackIgnore: true */ url);
} catch {
try { await new Promise((res, rej) =>
importScripts(url) ? res() : rej()); } catch { return false; }
}
return Object.keys(window).some(k => !before.includes(k));
} Type guard
const hasExportedAccessor = async (url) => {
const before = new Set(Object.keys(globalThis));
try { await import(url); } catch { return false; }
return Object.keys(globalThis).some(k => !before.has(k));
}; Try / catch
try {
await installLibrary(url);
} catch (e) {
if (/unique accessor/i.test(e?.message ?? '')) {
showToast('That script did not expose any global. Try a UMD/ESM build.');
} else throw e;
} Prevention
- Use a build that assigns to globalThis/window (UMD/IIFE) or exports an object (ESM).
- Point at the documented dist file, not a source or worker-bootstrap file.
- Verify in a browser console that loading the script defines a usable global.
- For ESM-only libs, use the jsDelivr +esm URL so a module object is produced.
When it happens
Trigger: Installing a script that runs but attaches nothing to the global scope (e.g. an IIFE that only registers a service worker, or a module whose exports were all consumed internally); a script that threw silently after load; an ESM module that resolved to a falsy/non-object value so the `if (module && typeof module === 'object')` branch was skipped.
Common situations: Adding a meta/polyfill script that has no export; choosing the wrong entry file (e.g. a worker bootstrap instead of the library bundle); a script that detects a non-browser context and bails out without defining globals.
Related errors
- Unable to generate a unique accessor
- The script at ${url} cannot be installed.
- Failed to generate autocomplete definitions for ${name}.
- Failed to load JS libraries
- Found a Promise() during evaluation. Data fields cannot exec
AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12).
Data as JSON: /api/errors/3620bd8db275e752.
Report an issue: GitHub.