Babel 6 regeneratorRuntime is not defined

前端 未结 30 1872
暖寄归人
暖寄归人 2020-11-22 03:49

I\'m trying to use async, await from scratch on Babel 6, but I\'m getting regeneratorRuntime is not defined.

.babelrc file

{
    \"presets\": [ \"es2         


        
30条回答
  •  广开言路
    2020-11-22 04:10

    I fixed this error by installing babel-polyfill

    npm install babel-polyfill --save
    

    then I imported it in my app entry point

    import http from 'http';
    import config from 'dotenv';
    import 'babel-polyfill';
    import { register } from 'babel-core';
    import app from '../app';
    

    for testing I included --require babel-polyfill in my test script

    "test": "export NODE_ENV=test|| SET NODE_ENV=test&& mocha --compilers 
      js:babel-core/register --require babel-polyfill server/test/**.js --exit"
    

提交回复
热议问题