vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.32k forks source link

Error: Cannot find module 'vue/compiler-sfc' #7216

Closed wuweiyuan closed 2 years ago

wuweiyuan commented 2 years ago

Version

5.0.6

Environment info

 System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.11 - /usr/local/bin/npm
  Browsers:
    Chrome: 103.0.5060.53
    Edge: Not Found
    Firefox: Not Found
    Safari: 13.1.3
  npmPackages:
    @mitojs/vue: ^3.0.1 => 3.0.1 
    @vue/babel-helper-vue-jsx-merge-props:  1.2.1 
    @vue/babel-helper-vue-transform-on:  1.0.2 
    @vue/babel-plugin-jsx:  1.1.1 
    @vue/babel-plugin-transform-vue-jsx:  1.2.1 
    @vue/babel-preset-app:  5.0.6 
    @vue/babel-preset-jsx:  1.2.4 
    @vue/babel-sugar-composition-api-inject-h:  1.2.1 
    @vue/babel-sugar-composition-api-render-instance:  1.2.4 
    @vue/babel-sugar-functional-vue:  1.2.2 
    @vue/babel-sugar-inject-h:  1.2.2 
    @vue/babel-sugar-v-model:  1.2.3 
    @vue/babel-sugar-v-on:  1.2.3 
    @vue/cli-overlay:  5.0.6 
    @vue/cli-plugin-babel: ~4.5.0 => 5.0.6 
    @vue/cli-plugin-eslint: ~4.5.0 => 5.0.6 
    @vue/cli-plugin-router: ~4.5.0 => 5.0.6 
    @vue/cli-plugin-typescript: ~4.5.0 => 5.0.6 
    @vue/cli-plugin-vuex: ~4.5.0 => 5.0.6 
    @vue/cli-service: ~4.5.0 => 5.0.6 
    @vue/cli-shared-utils:  5.0.6 
    @vue/compiler-core:  3.2.6 (3.0.0)
    @vue/compiler-dom:  3.2.6 (3.0.0)
    @vue/compiler-sfc: ^3.0.0 => 3.0.0 
    @vue/compiler-ssr:  3.0.0 
    @vue/component-compiler-utils:  3.3.0 
    @vue/devtools-api:  6.1.4 
    @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 
    @vue/eslint-config-typescript: ^9.1.0 => 9.1.0 
    @vue/reactivity:  3.2.6 
    @vue/runtime-core:  3.2.6 
    @vue/runtime-dom:  3.2.6 
    @vue/shared:  3.2.6 (3.0.0)
    @vue/web-component-wrapper:  1.3.0 
    eslint-plugin-vue: ^8.0.3 => 8.7.1 
    swiper/vue:  undefined ()
    typescript: ~4.5.5 => 4.5.5 
    vue: 3.2.6 => 3.2.6 
    vue-class-component: ^8.0.0-0 => 8.0.0-rc.1 
    vue-eslint-parser:  8.3.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  17.0.0 (15.9.8)
    vue-pdf: ^4.3.0 => 4.3.0 
    vue-resize-sensor:  2.0.0 
    vue-router: ^4.0.11 => 4.0.16 
    vue-style-loader:  4.1.3 
    vue-template-es2015-compiler:  1.9.1 
    vue-uuid: ^2.0.2 => 2.1.0 
    vuex: ^4.0.2 => 4.0.2 
  npmGlobalPackages:
    @vue/cli: 4.5.11

Steps to reproduce

Vuecli was upgraded from 4.5.0 to 5.0.6. An error was reported during project startup. Procedure steps: 1.vue upgrade

  1. npm run serve

What is expected?

Project started successfully

What is actually happening?

Error: Cannot find module 'vue/compiler-sfc' Require stack:

haoqunjiang commented 2 years ago

Please delete yarn.lock, package-lock.json, node_modules, and reinstall the dependencies. It's because your Vue version is outdated.