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

  1. Check module existence before unregistering: store.hasModule?.(path) or keep the register call paired with unregister in setup/teardown
  2. Only unregister modules added dynamically via registerModule
  3. Guard against double-cleanup with a flag
  4. 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

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


AI-assisted analysis of vuejs/vuex@bd907467b8 (2026-08-28). Data as JSON: /api/errors/8be05c1a6b947e9a. Report an issue: GitHub.