question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using vuex-module-decorators and @nuxtjs/auth together

See original GitHub issue

I am using nuxtjs with typescript and use vuex-module-decorators. but I get error when add @nuxtjs/auth to my project.

ERR_STORE_NOT_PROVIDED: To use getModule(), either the module should be decorated with store in decorator, i.e. @Module({store: store}) or store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)

This error happen when call Action.

When @nuxtjs/auth from modules it’s ok.

store/index.ts

import { Store } from "vuex";
import { initializeStores } from "~/utils/store-accessor";
const initializer = (store: Store<any>) => initializeStores(store);
export const plugins = [initializer];
export * from "~/utils/store-accessor";

utils/store-accessor

import { Store } from "vuex";
import { getModule } from "vuex-module-decorators";
import Login from "~/store/Login";
import App from "~/store/App";

let loginStore: Login, appStore: App;

function initializeStores(store: Store<any>): void {
	loginStore = getModule(Login, store);
	appStore = getModule(App, store);
}

export { initializeStores, loginStore, appStore };

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

3reactions
DenisNikonovcommented, Jul 29, 2020

You can try:

// nuxt.config.ts
auth: {
    vuex: false
}
1reaction
Hamidrezanacommented, Aug 9, 2020

@DenisNikonov This works but is lose accessing user info with $auth.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when using vuex-module-decorators and @nuxtjs/auth ...
I am using nuxtjs with typescript and use vuex-module-decorators. but I get error when add @nuxtjs/auth to my project.
Read more >
Error when using vuex-module-decorators and @nuxtjs/auth ...
I am using nuxtjs with typescript and use vuex-module-decorators. but I get error when add @nuxtjs/auth to my project.
Read more >
Error when using vuex-module-decorators and @nuxtjs/auth ...
Coding example for the question Error when using vuex-module-decorators and @nuxtjs/auth together-Vue.js.
Read more >
Error when using vuex-module-decorators and ... - DevPress
Answer a question I am using nuxtjs with typescript and use vuex-module-decorators. but I get error when add @nuxtjs/auth to my project.
Read more >
On this page - Nuxt Auth
user. This object contains details about authenticated user such as name. You can access it using either $auth or Vuex.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found