3

我的 CLI 版本是 4.5.8。我正在尝试安装 Vuetify,但出现了这个错误。有些人请帮我解决这个错误。

>vue add vuetify

�  Installing vue-cli-plugin-vuetify...

+ vue-cli-plugin-vuetify@2.0.7
updated 1 package in 27.591s

63 packages are looking for funding
  run `npm fund` for details

✔  Successfully installed plugin: vue-cli-plugin-vuetify

? Choose a preset: Default (recommended)

�  Invoking generator for vue-cli-plugin-vuetify...
 ERROR  Error: You cannot call "get" on a collection with no paths. Instead, check the "length" property first to verify at least 1 path exists.
Error: You cannot call "get" on a collection with no paths. Instead, check the "length" property first to verify at least 1 path exists.
    at Collection.get (C:\Program Files\nodejs\node_modules\@vue\cli\node_modules\jscodeshift\src\Collection.js:213:13)
    at injectOptions (C:\Program Files\nodejs\node_modules\@vue\cli\lib\util\codemods\injectOptions.js:15:6)
    at runTransformation (C:\Program Files\nodejs\node_modules\@vue\cli\node_modules\vue-codemod\dist\src\run-transformation.js:61:17)
    at C:\Program Files\nodejs\node_modules\@vue\cli\lib\Generator.js:290:23
    at Array.forEach (<anonymous>)
    at Generator.resolveFiles (C:\Program Files\nodejs\node_modules\@vue\cli\lib\Generator.js:276:24)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Generator.generate (C:\Program Files\nodejs\node_modules\@vue\cli\lib\Generator.js:175:5)
    at async runGenerator (C:\Program Files\nodejs\node_modules\@vue\cli\lib\invoke.js:111:3)
    at async invoke (C:\Program Files\nodejs\node_modules\@vue\cli\lib\invoke.js:92:3)
4

2 回答 2

3

此错误是由jscodeshift-powered 脚本引起的,该脚本旨在更新实例化的 Vue.js 实例,以便它了解 vuetify。

尝试使用 Vue.js v3 将 vuetify 添加到项目时出现此错误。不幸的是,在撰写本文时vuetify不支持 Vue.js v3 - https://vuetifyjs.com/en/introduction/roadmap/#v32e0-28titan29

因此,如果是这种情况,唯一可能的解决方案是切换到 Vue.js v2

于 2021-02-02T07:22:56.010 回答
0

在运行之前更新你的 main.js

vue add vuetify

Main.js (Vue 2)

new Vue({
    render: h => h(App)
}).$mount("#app");

安装后

new Vue({
  vuetify,
  render: h => h(App)
}).$mount('#app
于 2022-02-03T09:33:33.747 回答