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 'core-js/es6'
if I use this in a polyfill.js:
import 'core-js/es6';
That is my package.json:
{_x000D_
"name": "test",_x000D_
"version": "1.0.0",_x000D_
"main": "index.js",_x000D_
"license": "MIT",_x000D_
"private": true,_x000D_
"devDependencies": {_x000D_
"@babel/core": "^7.4.0",_x000D_
"@babel/preset-env": "^7.4.2",_x000D_
"@babel/preset-react": "^7.0.0",_x000D_
"@babel/runtime": "^7.4.2",_x000D_
"babel-loader": "^8.0.5",_x000D_
"babel-preset-es2015": "^6.24.1",_x000D_
"copy-webpack-plugin": "^5.0.2",_x000D_
"css-hot-loader": "^1.4.4",_x000D_
"eslint": "5.15.3",_x000D_
"eslint-config-airbnb": "^17.1.0",_x000D_
"eslint-loader": "^2.1.2",_x000D_
"eslint-plugin-import": "2.16.0",_x000D_
"eslint-plugin-jsx-a11y": "6.2.1",_x000D_
"eslint-plugin-react": "7.12.4",_x000D_
"file-loader": "^3.0.1",_x000D_
"node-sass": "^4.11.0",_x000D_
"prettier": "^1.16.4",_x000D_
"react-hot-loader": "4.8.0",_x000D_
"sass-loader": "^7.1.0",_x000D_
"webpack": "^4.29.6",_x000D_
"webpack-cli": "^3.3.0",_x000D_
"webpack-dev-server": "^3.2.1"_x000D_
},_x000D_
"dependencies": {_x000D_
"axios": "^0.18.0",_x000D_
"core-js": "^3.0.0",_x000D_
"prop-types": "^15.7.2",_x000D_
"react": "^16.8.5",_x000D_
"react-dom": "^16.8.5",_x000D_
"react-redux": "^6.0.1",_x000D_
"react-string-replace": "^0.4.1",_x000D_
"redux": "^4.0.1",_x000D_
"slick-carousel": "^1.8.1"_x000D_
},_x000D_
"scripts": {_x000D_
"dev": "webpack-dev-server --hot",_x000D_
"build": "webpack --colors --profile --progress --env.mode production",_x000D_
"lint": "eslint ./src/ --ext .js,.jsx"_x000D_
}_x000D_
}
_x000D_
Can someone help here?
This question is related to
npm
build
yarnpkg
package.json
After Migrated to Angular8, core-js/es6
or core-js/es7
Will not work.
You have to simply replace import core-js/es/
For ex.
import 'core-js/es6/symbol'
to
import 'core-js/es/symbol'
This will work properly.
Just change "target": "es2015" to "target": "es5" in your tsconfig.json.
Work for me with Angular 8.2.XX
Tested on IE11 and Edge
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
Change all "es6" and "es7" to "es" in your polyfills.ts and polyfills.ts (Optional).
import 'core-js/es6/symbol';
import 'core-js/es/symbol';
I found possible answer. You have core-js version 3.0, and this version doesn't have separate folders for ES6 and ES7; that's why the application cannot find correct paths.
To resolve this error, you can downgrade the core-js version to 2.5.7. This version produces correct catalogs structure, with separate ES6 and ES7 folders.
To downgrade the version, simply run:
npm i -S [email protected]
In my case, with Angular, this works ok.
Sure, I had a similar issue and a simple
npm uninstall @babel/polyfill --save &&
npm install @babel/polyfill --save
did the trick for me.
However, usage of @babel/polyfill is deprecated (according to this comment) so only try this if you think you have older packages installed or if all else fails.
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
Source: Stackoverflow.com