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.

Pinia not working

See original GitHub issue

Environment

  • Operating System: Linux
  • Node Version: v16.16.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: npm@8.11.0
  • Builder: vite
  • User Config: modules, buildModules, colorMode, typescript, experimental, vite
  • Runtime Modules: @nuxtjs/tailwindcss@5.3.2, @nuxtjs/color-mode@3.1.4, @vueuse/nuxt@9.1.0
  • Build Modules: @pinia/nuxt@0.4.0

Reproduction

I installed the pinia, added it to buildModule and got an error when starting nuxt. It worked fine on the RC 6.

Describe the bug

 ERROR  Cannot start nuxt:  Cannot find module 'pinia/dist/pinia.mjs'                                                                                                                                                10:34:41
Require stack:
- /home/nuxt3/index.js

  Require stack:
  - index.js
  at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
  at Function.resolve (node:internal/modules/cjs/helpers:108:19)
  at Function._resolve [as resolve] (node_modules/jiti/dist/jiti.js:1:108181)
  at resolveModule (node_modules/@pinia/nuxt/node_modules/@nuxt/kit/dist/index.mjs:276:29)
  at setup (node_modules/@pinia/nuxt/dist/module.mjs:22:32)
  at Object.normalizedModule (node_modules/@pinia/nuxt/node_modules/@nuxt/kit/dist/index.mjs:607:29)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:448:3)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:1495:7)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6768:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6813:5)

Additional context

No response

Logs

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:77 (9 by maintainers)

github_iconTop GitHub Comments

21reactions
BenjaminOddoucommented, Sep 15, 2022

After running npm install pinia @pinia/nuxt --legacy-peer-deps I removed pinia with npm uninstall pinia and for some reason it is working great like magic 🧙‍♂️

10reactions
sebj54commented, Sep 29, 2022

Here’s what worked for me:

  1. Install only @pinia/nuxt with npm or yarn
  2. Add an alias in your nuxt.config.ts file:
export default defineNuxtConfig({
    alias: {
        pinia: '/node_modules/@pinia/nuxt/node_modules/pinia/dist/pinia.mjs',
    },
    // your config
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Vuejs 3 Pinia not working, Cannot read properties of ...
I try to use Pinia but it never works ...
Read more >
Vue Pinia not working - StackBlitz
the [script setup docs](https://v3.vuejs.org/. api/sfc-script-setup.html#sfc-script-setup). to learn more. ## Recommended IDE Setup.
Read more >
Introduction - Pinia
I tested out ideas based on my experience developing applications, reading other people's code, working for clients who use Pinia, and answering questions...
Read more >
Pinia not installed? : r/vuejs - Reddit
The most common reason this error happens is when you are calling pinia before Vue initiates it.
Read more >
Vue 3: Support Pinia store : WEB-52890 - YouTrack
Yeah, this really is a bummer. Nothing works with pinia and webstorm within the SFC Template. It seems not a type script problem...
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