vue.js - 升级到 vue3 找不到模块 'vue-template-compiler/package.json'

标签 vue.js vuejs3

如本手册中所述 https://www.vuemastery.com/blog/vue-3-migration-build/
我更新了 package.json 添加了 vue.config.js 并运行了 yarn install 命令,并看到了这个错误

Error: Cannot find module 'vue-template-compiler/package.json'
Require stack:
- /myproject/node_modules/@vue/cli-service/lib/config/base.js
- /myproject/node_modules/@vue/cli-service/lib/Service.js
- /myproject/node_modules/@vue/cli-service/bin/vue-cli-service.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at /myproject/node_modules/@vue/cli-service/lib/config/base.js:73:32
    at /myproject/node_modules/@vue/cli-service/lib/Service.js:242:40
    at Array.forEach (<anonymous>)
    at Service.resolveChainableWebpackConfig (/myproject/node_modules/@vue/cli-service/lib/Service.js:242:26)
    at Service.resolveWebpackConfig (/myproject/node_modules/@vue/cli-service/lib/Service.js:246:48)
    at PluginAPI.resolveWebpackConfig (/myproject/node_modules/@vue/cli-service/lib/PluginAPI.js:138:25)
error Command failed with exit code 1.
我尝试更改编译器版本,但没有帮助
如何解决?
提前致谢

最佳答案

您添加了吗@vue/compiler-sfc ?请参阅此处的安装步骤 2:https://v3.vuejs.org/guide/migration/migration-build.html#installation

关于vue.js - 升级到 vue3 找不到模块 'vue-template-compiler/package.json',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69050275/

相关文章:

javascript - 使用自定义标签时避免 Vue 警告

javascript - 在没有 webpack 的情况下使用 vuejs 3 执行 bootstrap vue 组件

vue.js - 如何在 VueJS 中重新挂载组件?

javascript - 为什么当我将 axios.get() 数据传递给响应式对象 vuejs 时,我无法访问它?

javascript - Vue 3 组合 API 数据不是 react 性的

Vue.js - 使用 Vuelidate url 域应与电子邮件域匹配

laravel-5 - 使用 Laravel 5.3 的 Vue 多选

javascript - Vue.js 3 事件总线

javascript - Vue : template can't be keyed, 但不能用 div 替换模板 - 需要没有包装 div 元素的 v-for,嵌套的 v-for 循环

vue.js - 从外部 js/ts 文件调用 nuxt/axios 模块