Vue Cli 远程预设在调用生成器时崩溃
Vue Cli remote preset crashes on Invoking Generators
我正在尝试在 github 上创建远程 vue cli 预设,但由于某种原因,我不断收到语法错误。
我的预设仓库:https://github.com/christoph-schaeffer/vue-preset
我输入的命令:vue create --preset christoph-schaeffer/vue-preset testProject
我得到的错误:
Invoking generators...
ERROR SyntaxError: Identifier 'router' has already been declared (15:7)
SyntaxError: Identifier 'router' has already been declared (15:7)
at Object._raise (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:762:17)
at Object.raiseWithData (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:755:17)
at Object.raise (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:749:17)
at ScopeHandler.checkRedeclarationInScope (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:4826:12)
at ScopeHandler.declareName (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:4792:12)
at Object.checkLVal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:9367:22)
at Object.checkLVal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:865:15)
at Object.parseImportSpecifierLocal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12706:10)
at Object.maybeParseDefaultImportSpecifier (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12751:12)
at Object.parseImport (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12677:31)
起初它运行良好,然后我在 preset.json 中添加了一些东西以及一个生成器模板。
收到错误后,我尝试将整个回购恢复到它仍在工作时的状态。但是我仍然得到那个错误...
我想这与预设无关,而是我的全局 babel 包或其他问题?
我正在使用 vue-cli 版本 4,我正在开发 mac
任何关于如何获得此 运行 的指导将不胜感激
我找到问题了。
首先:vue cli 似乎以某种方式缓存了远程预设。这就是为什么即使在还原更改后它也不起作用的原因。
实际问题是,main.js 不应像其他模板文件那样更改,需要特别注意。出于某种奇怪的原因,只要您的模板中有 main.js,它就会给出这些随机错误。
如果有人对如何在预设中修改 main.js 感到好奇,请查看:
https://cli.vuejs.org/dev-guide/plugin-dev.html#changing-main-file
我正在尝试在 github 上创建远程 vue cli 预设,但由于某种原因,我不断收到语法错误。
我的预设仓库:https://github.com/christoph-schaeffer/vue-preset
我输入的命令:vue create --preset christoph-schaeffer/vue-preset testProject
我得到的错误:
Invoking generators...
ERROR SyntaxError: Identifier 'router' has already been declared (15:7)
SyntaxError: Identifier 'router' has already been declared (15:7)
at Object._raise (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:762:17)
at Object.raiseWithData (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:755:17)
at Object.raise (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:749:17)
at ScopeHandler.checkRedeclarationInScope (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:4826:12)
at ScopeHandler.declareName (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:4792:12)
at Object.checkLVal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:9367:22)
at Object.checkLVal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:865:15)
at Object.parseImportSpecifierLocal (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12706:10)
at Object.maybeParseDefaultImportSpecifier (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12751:12)
at Object.parseImport (/usr/local/lib/node_modules/@vue/cli/node_modules/@babel/parser/lib/index.js:12677:31)
起初它运行良好,然后我在 preset.json 中添加了一些东西以及一个生成器模板。
收到错误后,我尝试将整个回购恢复到它仍在工作时的状态。但是我仍然得到那个错误...
我想这与预设无关,而是我的全局 babel 包或其他问题?
我正在使用 vue-cli 版本 4,我正在开发 mac
任何关于如何获得此 运行 的指导将不胜感激
我找到问题了。
首先:vue cli 似乎以某种方式缓存了远程预设。这就是为什么即使在还原更改后它也不起作用的原因。
实际问题是,main.js 不应像其他模板文件那样更改,需要特别注意。出于某种奇怪的原因,只要您的模板中有 main.js,它就会给出这些随机错误。
如果有人对如何在预设中修改 main.js 感到好奇,请查看: https://cli.vuejs.org/dev-guide/plugin-dev.html#changing-main-file