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

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_
_x000D_
{_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_
_x000D_
_x000D_

Can someone help here?

This question is related to npm build yarnpkg package.json

The answer is


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).

  • From: import 'core-js/es6/symbol';
  • To: 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.


Make changes to your Polyfills.ts file

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


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


Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?

Examples related to build

error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' WARNING in budgets, maximum exceeded for initial How can I change the app display name build with Flutter? Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0) Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation' Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details Component is part of the declaration of 2 modules Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven

Examples related to yarnpkg

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app Module not found: Error: Can't resolve 'core-js/es6' Yarn: How to upgrade yarn version using terminal? Yarn install command error No such file or directory: 'install' How to install package from github repo in Yarn How Do I Uninstall Yarn How to clear cache in Yarn?

Examples related to package.json

SyntaxError: Cannot use import statement outside a module Module not found: Error: Can't resolve 'core-js/es6' Can not find module “@angular-devkit/build-angular” Error: EPERM: operation not permitted, unlink 'D:\Sources\**\node_modules\fsevents\node_modules\abbrev\package.json' Field 'browser' doesn't contain a valid alias configuration How do I add a custom script to my package.json file that runs a javascript file? "unexpected token import" in Nodejs5 and babel? Start script missing error when running npm start How to use private Github repo as npm dependency How to set environment variables from within package.json?