Static GitHub Issues

[2267] store.registerModule in plugin

prev: Nuxt scoped slot not working
next: Component inside nuxt-link is rendered twice

Hi !

I've a little problem here : I want to register a new store module in a plugin. In my plugin I do this :

import myStore from './store';

export default {
  install(Vue, { store }) {
    store.registerModule('custom', myStore);
  }
};

In my nuxt plugin I've this :

import CustomPlugin from './custom/plugin';

export default async ({ store }) => {
  Vue.use(CustomPlugin, { store });
};

Then I call an action in my page :

export default {
  async fetch ({ store }) {
    await store.dispatch('custom/FETCH');
  }
}

Everything is OK on client-side but on server-side, I've this error:

[vuex] unknown action type: custom/FETCH

I'm using nuxt-rc11 and my store files are located outside the root /store directory. It's possible to do that ?

Thanks !

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1986">#c1986</a>)</em></sub></div>