regeneratorRuntime is not defined 에러

김태완·2021년 12월 27일
0

프론트엔드

목록 보기
12/30

async/await를 사용하려는데 제목과 같은 에러가 발생해서 처리방법을 메모하려한다

async/await를 컴파일링 해주는 regenerator를 제공하기위해
@babel/plugin-transform-runtime 을 설치해준다.

npm i -save -d @babel/plugin-transform-runtime
npm i -save @babel/runtime

설치해주고 webpack.config.js에 아래와같이 추가해준다

plugins:[ "@babel/plugin-transform-runtime"]

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

위와같이 처리했을때, 해당 에러는 처리가 되지만 또 다른 에러가 발생한다.

github커뮤니티 댓글을 뒤져서 이와같은 문제를 해결한 내용을 확인했고
아래처럼 sourceTyptes를 추가해주면 해결된다.

plugins:[ "@babel/plugin-transform-runtime"]
sourceType: "unambiguous",

*babel공식문서에는 import/export사용시 module인지 script인지 구별해주는 기능이라고한다
https://babeljs.io/docs/en/options

profile
프론트엔드개발

0개의 댓글