blog icon indicating copy to clipboard operation
blog copied to clipboard

Module parse failed: Unexpected token

Open iq9891 opened this issue 4 years ago • 0 comments

技术

  • webpack 5
  • vue 3.1.1
  • typescript 4.2

问题

image

ERROR in ./components/upload-name/src/UploadName.vue?vue&type=template&id=aa469cec 2:2
Module parse failed: Unexpected token (2:2)
File was processed with these loaders:
 * ./node_modules/vue-loader/dist/index.js
You may need an additional loader to handle the result of these loaders.
|
>   <div :class="`${prefixClsNew}-wrapper`">
|     <div :class="prefixClsNew">
|       <a-upload

解决

在 webpack 配置中检查是否引入并使用 require('vue-loader').VueLoaderPlugin;

const vueLoaderPlugin = require('vue-loader').VueLoaderPlugin;

const weboackConfig = {
    plugins: [
        // ... other config
       new vueLoaderPlugin(),
    ]
}

iq9891 avatar Jun 18 '21 03:06 iq9891