{"record":{"id":"8be05c1a6b947e9a","repo":"vuejs/vuex","slug":"vuex-trying-to-unregister-module-key-which","errorCode":null,"errorMessage":"[vuex] trying to unregister module '${key}', which is not registered","messagePattern":"\\[vuex\\] trying to unregister module '(.+?)', which is not registered","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/module/module-collection.js","lineNumber":56,"sourceCode":"      parent.addChild(path[path.length - 1], newModule)\n    }\n\n    // register nested modules\n    if (rawModule.modules) {\n      forEachValue(rawModule.modules, (rawChildModule, key) => {\n        this.register(path.concat(key), rawChildModule, runtime)\n      })\n    }\n  }\n\n  unregister (path) {\n    const parent = this.get(path.slice(0, -1))\n    const key = path[path.length - 1]\n    const child = parent.getChild(key)\n\n    if (!child) {\n      if (__DEV__) {\n        console.warn(\n          `[vuex] trying to unregister module '${key}', which is ` +\n          `not registered`\n        )\n      }\n      return\n    }\n\n    if (!child.runtime) {\n      return\n    }\n\n    parent.removeChild(key)\n  }\n\n  isRegistered (path) {\n    const parent = this.get(path.slice(0, -1))\n    const key = path[path.length - 1]\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/vuejs/vuex/blob/bd907467b8392d6671bb115738285ff7f63d0cf6/src/module/module-collection.js#L38-L74","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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"],"exampleFix":"// before\nonUnmounted(() => store.unregisterModule('dynamicCart'))\n// after\nonUnmounted(() => { if (store.hasModule('dynamicCart')) store.unregisterModule('dynamicCart') })","handlingStrategy":"validation","validationCode":"function safeUnregister(store, path) {\n  const names = Array.isArray(path) ? path : [path]\n  if (typeof store.hasModule === 'function' && !store.hasModule(names)) return false\n  store.unregisterModule(names)\n  return true\n}","typeGuard":"function canUnregister(store, path) {\n  const names = Array.isArray(path) ? path : [path]\n  return typeof store.hasModule === 'function' && store.hasModule(names)\n}","tryCatchPattern":"try {\n  if (store.hasModule && store.hasModule('dynamicCart')) store.unregisterModule('dynamicCart')\n} catch (e) {\n  console.warn('unregister skipped', e)\n}","preventionTips":["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"],"tags":["vuex","module-registration","lifecycle","dev-warning"],"backgroundTag":"module-not-registered","analyzedSha":"bd907467b8392d6671bb115738285ff7f63d0cf6","analyzedAt":"2026-08-28T21:38:57.320Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}