OrchardCMS/OrchardCore · error · TypeError
Super expression must either be null or a function
Error message
Super expression must either be null or a function
What it means
Babel's _inherits helper throws this TypeError when class inheritance is compiled with a superclass that is neither a function nor null — i.e. the 'extends' expression did not evaluate to a constructor. Found in Font Awesome's bundled, transpiled fontawesome.js.
Solutions
- Fix script load order so the superclass module/bundle loads before fontawesome.js
- Resolve circular imports or undefined exports of the base class
- Check for duplicate/conflicting versions of libraries defining the parent class
- Verify the CDN/script tag wasn't blocked (404/ad-blocker) leaving the dependency undefined
Example fix
// before
class Icon extends SomeLibrary.Thing // SomeLibrary failed to load => undefined
// after
if (typeof SomeLibrary === 'undefined') { console.error('SomeLibrary must be loaded first'); } else { class Icon extends SomeLibrary.Thing {} } Defensive patterns
Strategy: validation
Validate before calling
if (typeof SuperClass !== 'function' && SuperClass !== null) throw new TypeError('Expected a constructor to extend'); Type guard
function isConstructor(v) { return typeof v === 'function' && v.prototype?.constructor === v || typeof v === 'function'; } Try / catch
try { initIcons(); } catch (e) { if (e instanceof TypeError && e.message.includes('Super expression')) console.error('A superclass bundle failed to load or export a class'); } Prevention
- Guarantee script load order for class-bearing bundles
- Check browser console/network for blocked (404) vendor scripts
- Watch for circular imports producing undefined classes
When it happens
Trigger: Compiled class code like class A extends B where B is undefined, an object, or a non-constructor value at the time _inherits(B) runs.
Common situations: Script load order problems so the base class isn't defined yet; circular imports leaving the superclass undefined; a minified/bundled dependency collision replacing a class with an object; broken UMD/global export from a CDN script failing to load first.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- @@toPrimitive must return a primitive value.
- @@toPrimitive must return a primitive value.
- @@toPrimitive must return a primitive value.
- Failed to load
- is missing the required "orchardBaseUrl" field.
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/6112a69934106169.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/fontawesome-free-6.7.2/js/fontawesome.js:18
/*!
* Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* Copyright 2024 Fonticons, Inc.
*/
(function () {
'use strict';
function _defineProperty(e, r, t) {
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[r] = t, e;
}
function _inherits(t, e) {
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
t.prototype = Object.create(e && e.prototype, {
constructor: {
value: t,
writable: !0,
configurable: !0
}
}), Object.defineProperty(t, "prototype", {
writable: !1
}), e && _setPrototypeOf(t, e);
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}View on GitHub (pinned to 4306c0717f)