Webpack打包vue文件的时候报错

[webpack-cli] Error: Cannot find module 'vue/compiler-sfc'

原因是我使用的是Vue2,而版本不对,以下是对应版本
Vue 3 requires vue-loader v16 + @vue/compiler-sfc;
Vue 2 requires vue-loader v15 + vue-template-compiler.

解决方式:降级使用15版本

$ cnpm i vue-loader@15 -D

参考
​​​https://github.com/vuejs/vue-loader/issues/1781#issuecomment-806661227​