search

Home  >  Q&A  >  body text

Module 'pinia/dist/pinia.mjs' not found when running dev

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粉393030917P粉393030917494 days ago1479

reply all(2)I'll reply

  • P粉038856725

    P粉0388567252023-10-27 21:49:45

    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 .

    reply
    0
  • P粉212971745

    P粉2129717452023-10-27 20:40:55

    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
    

    reply
    0
  • Cancelreply