You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel+Vue3项目集成Pinia报错:export 'default'未在'vue'中找到

Solution for "export 'default' (imported as 'Vue') was not found in 'vue'" in Vue3 + Pinia

This error happens because your code or a dependency is trying to import Vue as a default export—something that doesn’t exist in Vue3, which uses createApp instead of the global Vue instance. Your main initialization code is correct, so the issue lies elsewhere in your project.

Here are the steps to fix it:

  • Verify Pinia version compatibility
    Make sure you’re using Pinia v2.x, which is built for Vue3. Check your package.json or run npm list pinia in your terminal. If you have Pinia v1 (for Vue2), upgrade with:

    npm install pinia@latest
    
  • Audit your Pinia store files
    Look for any imports like import Vue from 'vue' in your store definitions. Pinia v2 doesn’t require this. A correct Vue3-compatible store should look like this:

    import { defineStore } from 'pinia'
    
    export const useAuthStore = defineStore('auth', {
      state: () => ({
        user: null,
        token: localStorage.getItem('token') || null
      }),
      actions: {
        login(token, user) {
          this.token = token
          this.user = user
          localStorage.setItem('token', token)
        },
        logout() {
          this.token = null
          this.user = null
          localStorage.removeItem('token')
        }
      }
    })
    
  • Check third-party dependencies
    If you’re using any authentication plugins or other Vue packages, confirm they’re compatible with Vue3. Older packages may still attempt to import the default Vue export. Update these packages or replace them with Vue3-friendly alternatives.

  • Clear cache and rebuild
    Sometimes cached dependencies cause unexpected issues. Delete your node_modules folder, package-lock.json (or yarn.lock), then run:

    npm install
    npm run dev # or your project's build command
    

内容的提问来源于stack exchange,提问作者Corristo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 16:12:47