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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With