vuejs/vuex · info
[vuex] trying to unregister module '${key}', which is not re
Error message
[vuex] trying to unregister module '${key}', which is not registered What it means
unregisterModule computed the parent module and looked up the child key, which does not exist. Vuex warns (dev only) and returns without throwing, so the call is a no-op indicating the target module was never registered or already removed.
Source
Thrown at src/module/module-collection.js:56
parent.addChild(path[path.length - 1], newModule)
}
// register nested modules
if (rawModule.modules) {
forEachValue(rawModule.modules, (rawChildModule, key) => {
this.register(path.concat(key), rawChildModule, runtime)
})
}
}
unregister (path) {
const parent = this.get(path.slice(0, -1))
const key = path[path.length - 1]
const child = parent.getChild(key)
if (!child) {
if (__DEV__) {
console.warn(
`[vuex] trying to unregister module '${key}', which is ` +
`not registered`
)
}
return
}
if (!child.runtime) {
return
}
parent.removeChild(key)
}
isRegistered (path) {
const parent = this.get(path.slice(0, -1))
const key = path[path.length - 1]
View on GitHub (pinned to bd907467b8)
Solutions
- Check module existence before unregistering: store.hasModule?.(path) or keep the register call paired with unregister in setup/teardown
- Only unregister modules added dynamically via registerModule
- Guard against double-cleanup with a flag
- Ignore the warning if idempotent teardown is intended
Example fix
// before
onUnmounted(() => store.unregisterModule('dynamicCart'))
// after
onUnmounted(() => { if (store.hasModule('dynamicCart')) store.unregisterModule('dynamicCart') }) Defensive patterns
Strategy: validation
Validate before calling
function safeUnregister(store, path) {
const names = Array.isArray(path) ? path : [path]
if (typeof store.hasModule === 'function' && !store.hasModule(names)) return false
store.unregisterModule(names)
return true
} Type guard
function canUnregister(store, path) {
const names = Array.isArray(path) ? path : [path]
return typeof store.hasModule === 'function' && store.hasModule(names)
} Try / catch
try {
if (store.hasModule && store.hasModule('dynamicCart')) store.unregisterModule('dynamicCart')
} catch (e) {
console.warn('unregister skipped', e)
} Prevention
- Pair every registerModule with exactly one unregister (setup/teardown symmetry)
- Use store.hasModule (Vuex 3.5+/4) before unregistering
- Never unregister modules defined statically in createStore options
- Track dynamically registered module names in a Set to make cleanup idempotent
When it happens
Trigger: Calling store.unregisterModule('foo') when 'foo' is not a child of root, or unregisterModule(['a','b']) when path 'b' was never registered under 'a'; double-unregister after HMR or teardown.
Common situations: Component unmount code unconditionally unregistering a lazily-added module; calling unregisterModule for modules defined statically in the store options (they were never separately registered); duplicate cleanup paths (e.g. both watcher and unmounted hook).
Related errors
- [vuex] state field "${moduleName}" was overridden by a modul
- [vuex] trying to add a new module '${key}' on hot reloading,
- Missing module "${moduleName}" for path "${path}".
- [vuex] ${msg}
- [vuex] error in before action subscribers:
AI-assisted analysis of vuejs/vuex@bd907467b8 (2026-08-28).
Data as JSON: /api/errors/8be05c1a6b947e9a.
Report an issue: GitHub.