Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'pinia/dist/pinia.mjs' when using run dev

I setup Pinia on top of fresh Nuxt3 app and start dev server, with exactly these commands in order:

npx nuxi init nuxt-app
cd nuxt-app
npm install
npm install @pinia/nuxt
npm run dev

Dev server runs without any problem. Then, i put this line of code into "nuxt.config.ts";

export default defineNuxtConfig({
  modules: ["@pinia/nuxt"],
});

And, when I again try to connect to dev server, it gives me this error message in terminal:

 ERROR  Cannot start nuxt:  Cannot find module 'pinia/dist/pinia.mjs'                                                                     12:03:55
Require stack:
- C:\Users\user\Documents\github2\nuxt-app\index.js
like image 749
Clarity Avatar asked Aug 31 '25 04:08

Clarity


2 Answers

Apparently this is now fixed.


As mentioned here, there is an issue with NPM not doing it's job properly, here is how you can solve it:

npm i pinia -f
like image 77
kissu Avatar answered Sep 02 '25 17:09

kissu


As I know this is a bug that will be fixed someday. Until then you can put

alias: {
  pinia: "/node_modules/@pinia/nuxt/node_modules/pinia/dist/pinia.mjs"
},

in your nuxt.config.ts and it will work.

Found from this VueSchool lesson on Pinia.

like image 32
dust_bg Avatar answered Sep 02 '25 19:09

dust_bg