Module not found: Error: Can't resolve 'core-js/es6'

后端 未结 9 1123
轻奢々
轻奢々 2020-12-12 14:49

I\'ve got a problem with my build process in relation to my React app.

I always get the following error:

Module not found: Error: Can\'t resolve \'co

相关标签:
9条回答
  • 2020-12-12 15:20

    If you use @babel/preset-env and useBuiltIns, then you just have to add corejs: 3 beside the useBuiltIns option, to specify which version to use, default is corejs: 2.

    presets: [
      [
        "@babel/preset-env", {
          "useBuiltIns": "usage",
          "corejs": 3
        }
      ]
    ],
    

    For further details see: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpreset-env

    0 讨论(0)
  • 2020-12-12 15:23

    Change all "es6" and "es7" to "es" in your polyfills.ts and polyfills.ts

    0 讨论(0)
  • 2020-12-12 15:24

    The imports have changed for core-js version 3.0.1 - for example

    import 'core-js/es6/array'; and import 'core-js/es7/array';

    can now be provided simply by the following

    import 'core-js/es/array';

    if you would prefer not to bring in the whole of core-js

    0 讨论(0)
提交回复
热议问题