Home

Issue: 2267

store.registerModule in plugin

[issue link]

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 !

This question is available on Nuxt.js community (#c1986)