Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@pinia/nuxt doesn't work with nuxt bridge #889

Closed
caikan opened this issue Dec 8, 2021 · 7 comments
Closed

@pinia/nuxt doesn't work with nuxt bridge #889

caikan opened this issue Dec 8, 2021 · 7 comments

Comments

@caikan
Copy link

caikan commented Dec 8, 2021

Reproduction

https://codesandbox.io/s/brave-danilo-n1de5

Steps to reproduce the behavior

Create a project with nuxt-bridge and @pinia/nuxt.
npm run dev
Open in browser.

Expected behavior

No error.

Actual behavior

500
Cannot read properties of undefined (reading 'install')
at Function.Vue.use (file://./.nuxt/dist/server/server.mjs:7842:23)
at $id_c39524e4 (file://./.nuxt/dist/server/server.mjs:20715:7)
at async __instantiateModule__ (file://./.nuxt/dist/server/server.mjs:20913:3)

Additional information

N/A

@posva
Copy link
Member

posva commented Dec 8, 2021

This is because your app is empty: no app.vue or pages/index.vue. Here is a working example: https://github.com/piniajs/example-nuxt-bridge

@posva posva closed this as completed Dec 8, 2021
@caikan
Copy link
Author

caikan commented Dec 8, 2021

I tried again. I found that it's because I turned on the vite option, not no app.vue or pages/index.vue.

@posva
Copy link
Member

posva commented Dec 8, 2021

Can you try out if #781 fixes it for you?

@caikan
Copy link
Author

caikan commented Dec 8, 2021

I checked out https://github.com/tobiasdiez/pinia/tree/patch-1, and built locally by yarn run build, then npm link @pinia/nuxt in the repro, but the problem still exists.

@BobbieGoede
Copy link

I managed to workaround the Cannot read properties of undefined (reading 'install') issue by adding an alias to the vite config in nuxt.config. This gave me a different error: [vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function.

Adding the following to nuxt.config got rid of both errors for me.

vite: {
    optimizeDeps: {
        exclude: ['pinia'],
    },
    resolve: {
        alias: {
            pinia: path.resolve(__dirname, './node_modules/pinia/dist/pinia.mjs'),
        },
    },
}

@psycongaroo
Copy link

same problem

@psycongaroo
Copy link

with vite is getting the error:

Cannot read properties of undefined (reading 'install') at Function.Vue.use (file://./.nuxt/dist/server/server.mjs:7842:23) at $id_c39524e4 (file://./.nuxt/dist/server/server.mjs:20715:7) at async __instantiateModule__ (file://./.nuxt/dist/server/server.mjs:20913:3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants