프로그래밍 공부하기

[Babel] regeneratorRuntime is not defined 본문

ErrorLog

[Babel] regeneratorRuntime is not defined

ihl 2021. 6. 17. 13:45

  es8 문법인 async / await을 사용하면 'regeneratorRuntime is not defined' 라는 에러가 발생한다. 이 때는 추가적인 플러그인을 설치하여 적용하면 된다.

npm install --save-dev @babel-plugin-transform-runtime
npm install --save @babel-runtime

 

  babel-plugin-transform-runtime과 babel-runtime을 설치한다. 이 때 babel-runtime은 --save 옵션으로 설치해야한다.

 module: {
    rules: [
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            plugins: ['@babel/plugin-transform-runtime'], //추가!
            presets: ['@babel/preset-env']
          }
        }
      }
    ]
  }

  웹팩 설정파일에 설치한 plugin-transform-runtime을 추가해주자. 참고로 babel/polyfill도 해결로도 해결이 된다고 하는데 Babel 7.4.0부터 더이상 사용되지 않는다고 한다..

 


참고: https://stackoverflow.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined

'ErrorLog' 카테고리의 다른 글

Could not find a package.json file.  (0) 2021.07.19
[AWS] Access Denied  (0) 2021.06.23
VSCode 중괄호 포맷 변경  (0) 2021.06.01
[PowerShell] UnauthorizedAccess  (0) 2021.05.14
ELB 502 Error  (3) 2021.04.30
Comments