How do I install the babel-polyfill library?

后端 未结 7 1210
旧时难觅i
旧时难觅i 2020-12-02 06:13

I just started to use Babel to compile my ES6 javascript code into ES5. When I start to use Promises it looks like it\'s not working. The Babel website states support for pr

相关标签:
7条回答
  • 2020-12-02 07:08

    Like Babel says in the docs, for Babel > 7.4.0 the module @babel/polyfill is deprecated, so it's recommended to use directly core-js and regenerator-runtime libraries that before were included in @babel/polyfill.

    So this worked for me:

    npm install --save core-js@3.6.5
    npm install regenerator-runtime
    

    then add to the very top of your initial js file:

    import 'core-js/stable';
    import 'regenerator-runtime/runtime';
    
    0 讨论(0)
提交回复
热议问题