Search code examples
javascriptvue.jsnuxt.jsnuxt3.jspinia

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

Solution

  • 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