Cant resolve core-js/es6/array

Questions : Module not found: Error: Cant resolve core-jses6

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00

876

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

I always get the following error:

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

if I use this in a polyfill.js:

import 'core-js/es6';

That is my package.json:

{ "name": "test", "version": "1.0.0", "main": "index.js", "license": "MIT", "private": true, "devDependencies": { "@babel/core": "^7.4.0", "@babel/preset-env": "^7.4.2", "@babel/preset-react": "^7.0.0", "@babel/runtime": "^7.4.2", "babel-loader": "^8.0.5", "babel-preset-es2015": "^6.24.1", "copy-webpack-plugin": "^5.0.2", "css-hot-loader": "^1.4.4", "eslint": "5.15.3", "eslint-config-airbnb": "^17.1.0", "eslint-loader": "^2.1.2", "eslint-plugin-import": "2.16.0", "eslint-plugin-jsx-a11y": "6.2.1", "eslint-plugin-react": "7.12.4", "file-loader": "^3.0.1", "node-sass": "^4.11.0", "prettier": "^1.16.4", "react-hot-loader": "4.8.0", "sass-loader": "^7.1.0", "webpack": "^4.29.6", "webpack-cli": "^3.3.0", "webpack-dev-server": "^3.2.1" }, "dependencies": { "axios": "^0.18.0", "core-js": "^3.0.0", "prop-types": "^15.7.2", "react": "^16.8.5", "react-dom": "^16.8.5", "react-redux": "^6.0.1", "react-string-replace": "^0.4.1", "redux": "^4.0.1", "slick-carousel": "^1.8.1" }, "scripts": { "dev": "webpack-dev-server --hot", "build": "webpack --colors --profile --progress --env.mode production", "lint": "eslint ./src/ --ext .js,.jsx" } }

Can someone help here?

Total Answers 12

29

Answers 1 : of Module not found: Error: Cant resolve core-jses6

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

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

can now be provided simply by the anycodings_yarnpkg following

import 'core-js/es/array';

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

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

mRahman

5

Answers 2 : of Module not found: Error: Cant resolve core-jses6

I found possible answer. You have anycodings_yarnpkg core-js version 3.0, and this version anycodings_yarnpkg doesn't have separate folders for ES6 anycodings_yarnpkg and ES7; that's why the application anycodings_yarnpkg cannot find correct paths.

To resolve this error, you can downgrade anycodings_yarnpkg the core-js version to 2.5.7. This anycodings_yarnpkg version produces correct catalogs anycodings_yarnpkg structure, with separate ES6 and ES7 anycodings_yarnpkg folders.

To downgrade the version, simply run:

npm i -S

In my case, with Angular, this works ok.

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

joy

4

Answers 3 : of Module not found: Error: Cant resolve core-jses6

Change all "es6" and "es7" to "es" in anycodings_yarnpkg your polyfills.ts and polyfills.ts anycodings_yarnpkg (Optional).

  • From: import 'core-js/es6/symbol';
  • To: import 'core-js/es/symbol';

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

jidam

4

Answers 4 : of Module not found: Error: Cant resolve core-jses6

After Migrated to New Angular Version or anycodings_yarnpkg Version changed for core-js, core-js/es6 anycodings_yarnpkg or core-js/es7 Will not work.

You have to simply replace import anycodings_yarnpkg core-js/es/ in your polyfills.ts file.

For ex.

import 'core-js/es6/symbol'

to

import 'core-js/es/symbol'

This will work properly.

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

joy

2

Answers 5 : of Module not found: Error: Cant resolve core-jses6

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

example:

import 'core-js/es6/reflect';

becomes

import 'core-js/es/reflect';

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

jidam

4

Answers 6 : of Module not found: Error: Cant resolve core-jses6

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

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

For further details see: anycodings_yarnpkg //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

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

raja

5

Answers 7 : of Module not found: Error: Cant resolve core-jses6

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 anycodings_yarnpkg deprecated (according to this comment) anycodings_yarnpkg so only try this if you think you have anycodings_yarnpkg older packages installed or if all else anycodings_yarnpkg fails.

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

miraj

5

Answers 8 : of Module not found: Error: Cant resolve core-jses6

Ended up to have a file named anycodings_yarnpkg polyfill.js in anycodings_yarnpkg projectpath\src\polyfill.js That file anycodings_yarnpkg only contains this line: import anycodings_yarnpkg 'core-js'; this polyfills not only es-6, anycodings_yarnpkg but is the correct way to use core-js anycodings_yarnpkg since version 3.0.0.

I added the polyfill.js to my anycodings_yarnpkg webpack-file entry attribute like this:

entry: ['./src/main.scss', anycodings_yarnpkg './src/polyfill.js', './src/main.jsx']

Works perfectly.

I also found some more information here anycodings_yarnpkg : anycodings_yarnpkg //github.com/zloirock/core-js/issues/184

The library author (zloirock) claims:

ES6 changes behaviour almost all anycodings_yarnpkg features added in ES5, so core-js/es6 anycodings_yarnpkg entry point includes almost all of them. anycodings_yarnpkg Also, as you wrote, it's required for anycodings_yarnpkg fixing broken browser implementations.

(Quotation anycodings_yarnpkg //github.com/zloirock/core-js/issues/184 anycodings_yarnpkg from zloirock)

So I think import 'core-js'; is just anycodings_yarnpkg fine.

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

jidam

3

Answers 9 : of Module not found: Error: Cant resolve core-jses6

Just change "target": "es2015" to anycodings_yarnpkg "target": "es5" in your tsconfig.json.

Work for me with Angular 8.2.XX

Tested on IE11 and Edge

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

joy

4

Answers 10 : of Module not found: Error: Cant resolve core-jses6

I got this error today (13 April 2022) anycodings_yarnpkg after upgrade core-js version from 2 to anycodings_yarnpkg 3 and after I tried to find the answer anycodings_yarnpkg for several Hour, finally I can solved anycodings_yarnpkg it after update my babel.config.js and anycodings_yarnpkg make it like this:

Before:

presets: [ "@vue/app" ]

After:

presets: [ [ "@vue/app", { useBuiltIns: "entry" } ] ]

Notes

  1. I'm using Vue in my project

  2. I already try almost all question anycodings_yarnpkg regarding npm uninstall core-js and anycodings_yarnpkg tried to re-install it again npm install anycodings_yarnpkg core-js --save or delete node_modules, anycodings_yarnpkg package-lock.json, and yarn-lock.json anycodings_yarnpkg but still failed to solved it

  3. I can solved it if I downgrade core-js anycodings_yarnpkg version using this line : npm install anycodings_yarnpkg , but it is not a good anycodings_yarnpkg solution for long term condition

  4. Explanation for this problem: this anycodings_yarnpkg problem happens because the path for anycodings_yarnpkg core-js/es6 in version 3 is already anycodings_yarnpkg changed to core-js/es that's why your anycodings_yarnpkg project can't find it the right path for anycodings_yarnpkg the directory where it pointed to anycodings_yarnpkg core-js/es6

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

miraj

4

Answers 11 : of Module not found: Error: Cant resolve core-jses6

It is vital that Webpack is able to anycodings_yarnpkg resolve the import statements prepended anycodings_yarnpkg to source files by Babel, for example

import "core-js/modules/es.object.freeze.js";

If such an import statement is inserted anycodings_yarnpkg into a file which does not reside in a anycodings_yarnpkg package which has core-js as a anycodings_yarnpkg dependency, then Webpack may not be able anycodings_yarnpkg to resolve its location on disk, anycodings_yarnpkg resulting in a ModuleNotFoundError.

The solution for me was to specify the anycodings_yarnpkg application's node_modules directory in anycodings_yarnpkg the resolve section of my anycodings_yarnpkg webpack.config.cjs:

module.exports = { resolve: { modules: [ path.join(__dirname, "node_modules"), // Contains core-js. "node_modules" // Webpack's default. ] } }

And of course core-js is listed as a anycodings_yarnpkg dependency in my application's anycodings_yarnpkg package.json:

{ "dependencies": { "core-js": "^3.19.3" } }

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

jidam

3

Answers 12 : of Module not found: Error: Cant resolve core-jses6

For Angular 14 I had to run npm i --save anycodings_yarnpkg core-js

I kept the polyfills the same as in the anycodings_yarnpkg Amplify docs:

import 'core-js/es/typed-array'; import 'core-js/es/object';

0

2022-09-23T02:07:33+00:00 2022-09-23T02:07:33+00:00Answer Link

joy

Toplist

Latest post

TAGs