nuxt 에서 vee-validator3 사용시 "Unexpected Token: export" 에러날때 > IT 기술백서

IT 기술백서

직접 알아내거나 검색하기 귀찮아서 모아 둔 것

JavaScript | nuxt 에서 vee-validator3 사용시 "Unexpected Token: export" 에러날때

본문

nuxt 는 트랜스파일(비슷한 수준의 다른언어로 변환하는 것)할때 node_modules 는 무시한다.

그래서 /vee-validate/dist/rules 를 build 섹션에 포함해줘야 한다.

 

nuxt.config.js 의 build 섹션에 아래를 추가하면 된다.

 

[code]

build: {

  transpile: ['vee-validate/dist/rules'],

}

[/code] 

 

공식문서에는 아래와 같이 안내되어 있다.

 

By default Nuxt ignores transpilation of the node_modules folder,

and since the rules.js is an ES6 export. 

You should add vee-validate/dist/rules to the list of sources that will be transpiled.

Otherwise you might run into "Unexpected Token: export" errors.

 

https://vee-validate.logaretm.com/v3/guide/rules.html#importing-rules-in-nuxt-js

댓글 0개

등록된 댓글이 없습니다.

Menu