mobxjs/mobx · error
[MobX] ${e}
Error message
[MobX] ${e} What it means
MobX's internal die() raises all developer-facing invariant violations. In __DEV__ builds it resolves a message key or template from the niceErrors table (optionally formatting it with args) and throws `[MobX] <message>`. It is the single funnel for every 'you used MobX wrong' assertion, so the specific message after [MobX] tells you which invariant was violated.
Source
Thrown at packages/mobx/src/errors.ts:97
},
43(annotationType, name, kind) {
return (
`Cannot apply '${annotationType}' to '${name}' (kind: ${kind}):` +
`\n'${annotationType}' can only be used on properties with a function value.`
)
},
44(annotationType) {
return `'${annotationType}' can only be used with 'makeObservable'`
}
} as const
const errors: typeof niceErrors = __DEV__ ? niceErrors : ({} as any)
export function die(error: string | keyof typeof errors, ...args: any[]): never {
if (__DEV__) {
let e: any = typeof error === "string" ? error : errors[error]
if (typeof e === "function") e = e.apply(null, args as any)
throw new Error(`[MobX] ${e}`)
}
throw new Error(
`[MobX] minified error nr: ${error}${
args.length ? " " + args.map(String).join(",") : ""
}. See mobx.js.org/errors`
)
}
View on GitHub (pinned to 01211a698b)
Solutions
- Read the text after the `[MobX]` prefix — it is the specific violation — and fix the offending call
- Look up the error text at mobx.js.org/errors for the detailed explanation
- Ensure decorator/annotation targets match their types (observable on properties, action on methods, etc.)
- Pass valid arguments: check the API signature for autorun/reaction/computed/extendObservable
Example fix
// before
computed(() => this.value * 2) // called as method, invalid usage
// after
get doubled() { return this.value * 2 } // or makeObservable(this, { doubled: computed }) Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
function isMobxError(e: unknown): e is Error & { message: string } {
return e instanceof Error && e.message.startsWith('[MobX] ')
} Try / catch
try {
autorun(() => { /* ... */ })
} catch (e) {
if (e instanceof Error && e.message.startsWith('[MobX] ')) {
console.error('MobX invariant violated:', e.message.replace('[MobX] ', ''))
} else throw e
} Prevention
- Read the text after [MobX] and consult mobx.js.org/errors
- Validate decorator/annotation targets against MobX's expectations
- Keep API arguments matching current-version signatures
- Run a dev build in CI to surface invariants with full messages
When it happens
Trigger: Any MobX API invariant violation funneled through die(), e.g. calling autorun/reaction/computed with invalid arguments, misusing extendObservable, applying a decorator annotation to the wrong kind of member (assert20223DecoratorType), or passing an error code key from the errors table.
Common situations: Misconfigured decorators on non-observable class members; calling APIs with wrong arity/types; state mutations outside actions with enforceActions enabled; version-mismatched usage patterns after upgrading MobX.
Related errors
- mobx-react-lite requires mobx at least version 7 to be avail
- mobx-react requires mobx to be available
- [mobx-react] Cannot read "${admin.name}.${key}" in a reactiv
- [MobX] minified error nr: ${error}${args.length ? " " + args
- WARNING: Debug feature only. MobX will NOT recover from erro
AI-assisted analysis of mobxjs/mobx@01211a698b (2026-08-28).
Data as JSON: /api/errors/0504e47147588fe9.
Report an issue: GitHub.