Cannot read property 'parseComponent' of undefined

发布于 2022-09-12 13:00:30 字数 1778 浏览 16 评论 0

错误内容

ERROR in ./src/vue/App.vue
Module Error (from ./node_modules/vue-loader/lib/index.js):

Vue packages version mismatch:

- vue@3.0.0 (/Users/stephanie/Desktop/webpack/node_modules/vue/index.js)
- vue-template-compiler@2.6.12 (/Users/stephanie/Desktop/webpack/node_modules/vue-template-compiler/package.json)

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.
 @ ./src/main.js 7:0-32 10:7-10

ERROR in ./src/vue/App.vue
Module build failed (from ./node_modules/vue-loader/lib/index.js):
TypeError: Cannot read property 'parseComponent' of undefined
    at parse (/Users/stephanie/Desktop/webpack/node_modules/@vue/component-compiler-utils/dist/parse.js:15:23)
    at Object.module.exports (/Users/stephanie/Desktop/webpack/node_modules/vue-loader/lib/index.js:67:22)
 @ ./src/main.js 7:0-32 10:7-10

webpack 5.1.0 compiled with 2 errors in 4436 ms

package.json

    "vue-loader": "^15.9.3",
    "vue-template-compiler": "^2.6.12",
    "webpack": "^5.1.0",
    "vue"":"^3.0.0"

webpack.config.js

 const VueLoaderPlugin = require('vue-loader/lib/plugin')
 module:{
           rules:
               { 
              
                   test: /\.vue$/,
                   loader: 'vue-loader'
                },
        },
  
  
 plugins: [
            new VueLoaderPlugin()
  ],

尝试过的方法

npm update vue-template-compiler ; 把vue-template-compiler升级最新版本,目前最新版本:2.6.12

补充

通过 vue-cli 创建的基于vue3.0 项目是没有问题.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2022-09-19 13:00:30
  • 使用最新版本vue应该没有问题的
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文