Module 'pinia/dist/pinia.mjs' not found when running dev
P粉393030917
P粉393030917 2023-10-26 23:04:01
0
2
1275

I set up Pinia on top of a new Nuxt3 application and started the development server, using the following commands in sequence:

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

The development server runs without any problems. Then I put this line of code into "nuxt.config.ts";

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

And, when I tried to connect to the development server again, it gave this error message in the terminal:

ERROR  Cannot start nuxt:  Cannot find module 'pinia/dist/pinia.mjs'                                                                     12:03:55
Require stack:
- C:UsersuserDocumentsgithub2nuxt-appindex.js


P粉393030917
P粉393030917

reply all(2)
P粉038856725

As far as I know, this is a bug and 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 it will work.

Found from About Pinia’s VueSchool course .

P粉212971745

As mentioned here, there is a problem with NPM not performing the operation, which works fine, and the solution is as follows:

npm i pinia -f
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template