gpt4 book ai didi

node.js - Vue 3 : TypeError: compiler. parseComponent 不是函数

转载 作者:行者123 更新时间:2023-12-03 12:12:48 32 4
gpt4 key购买 nike

我似乎无法摆脱这个错误。
我试过删除 package-lock.json & node_modules其次是 npm install ,但是,它不起作用。

  • Node 版本:12.18.3
  • NPM 版本:6.14.8

  • 任何帮助表示赞赏!

    可爱的错误
    ERROR in ./src/scripts/Test.vue
    Module build failed (from ./node_modules/vue-loader/lib/index.js):
    TypeError: compiler.parseComponent is not a function
    at parse (some path\node_modules\@vue\component-compiler-utils\dist\parse.js:15:23)
    at Object.module.exports (some path\node_modules\vue-loader\lib\index.js:67:22)
    @ ./src/scripts/app.js 8:0-30 10:10-14
    package.json
    {
    "name": "app",
    "version": "1.0.0",
    "description": "",
    "private": true,
    "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "devDependencies": {
    "@vue/compiler-sfc": "^3.0.2",
    "vue-loader": "^15.9.4",
    "webpack": "^4.44.1",
    "webpack-cli": "^3.3.12"
    },
    "dependencies": {
    "vue": "^3.0.2"
    }
    }
    webpack.config.js
    const path = require('path');
    const VueLoaderPlugin = require('vue-loader/lib/plugin');

    module.exports = {
    mode: 'development',
    entry: './src/scripts/app.js',
    output: {
    filename: 'scripts/app.js'
    },
    plugins: [
    new VueLoaderPlugin()
    ],
    module: {
    rules: [
    {
    test: /\.vue$/,
    use: [
    {
    loader: 'vue-loader',
    options: {
    // Fixes the "vue-template-compiler" error.
    compiler: require('@vue/compiler-sfc')
    }
    }
    ]
    }
    ]
    },
    watch: true
    };
    src/scripts/app.js
    import { createApp } from 'vue';
    import Test from './Test.vue';

    createApp(Test).mount('#app');
    src/scripts/Test.vue
    <template>
    <p>{{ message }}</p>>
    </template>

    <script>
    export default {
    data() {
    return {
    message: "I'm giving up!"
    }
    }
    }
    </script>

    最佳答案

    解决问题的步骤:

  • 升级 vue-loader^16.0.0-beta.9 .
  • 更改 const VueLoaderPlugin = require('vue-loader/lib/plugin');const { VueLoaderPlugin } = require('vue-loader'); .
  • 关于node.js - Vue 3 : TypeError: compiler. parseComponent 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64587600/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com