Vue Cli 원격 사전 설정이 생성기 호출에서 충돌 함

Aug 19 2020

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에 몇 가지 항목을 추가했습니다.

오류가 발생한 후 전체 저장소를 여전히 작동 중일 때의 상태로 되돌리려 고했습니다. 그러나 여전히 그 오류가 발생합니다 ...

나는 그것이 실제로 프리셋에 관한 것이 아니라 내 글로벌 바벨 패키지 또는 뭔가 문제가 있다고 생각합니까?

vue-cli 버전 4를 사용하고 있으며 Mac에서 작업 중입니다.

이 실행 방법에 대한 모든 지침은 매우 감사하겠습니다.

답변

ChristophDietrich Aug 19 2020 at 16:38

문제를 발견했습니다.

첫째, vue cli는 어떻게 든 원격 사전 설정을 캐시하는 것처럼 보입니다. 이것이 변경 사항을 되 돌린 후에도 작동하지 않는 이유입니다.

실제 문제는 main.js가 다른 템플릿 파일처럼 변경되어서는 안되며 특별한주의가 필요하다는 것입니다. 이상한 이유로 템플릿에 main.js가 있으면 즉시 임의의 오류가 발생합니다.

미리 설정된 체크 아웃에서 main.js를 수정하는 방법에 대해 궁금한 사람이 있다면 https://cli.vuejs.org/dev-guide/plugin-dev.html#changing-main-file