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

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

An error is reported when webpack packages Vue files

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

The reason is that I use vue2, but the version is wrong. The following is the corresponding version
Vue 3 requires Vue-loader V16 + @Vue/compiler-sfc
Vue 2 requires vue-loader v15 + vue-template-compiler.

Solution: downgrade to version 15

$ cnpm i [email protected] -D

Read More: