babel 6 async / await: Unexpected token

前端 未结 5 2024
眼角桃花
眼角桃花 2021-02-07 09:33

Im having trouble getting async / await transforms working. What am I missing?

My .babelrc:

{
  \"presets\": [ \"es2015\", \"stage-0\" ]
}
5条回答
  •  醉话见心
    2021-02-07 10:07

    You can compile them yourself using the transform-async-to-module-method plugin, this allows you to compile them down to bluebird co-routines which requires ES6 generators (available in node4).

    Or if you need to compile it back to ES5 so it's compatible for browsers you can use transform-async-to-generator and facebook's regenerator.

    I've written about how to set up your babel config here http://madole.xyz/async-await-es7/

提交回复
热议问题