Closed mudasserzahid closed 5 years ago
Which version of @angular-devkit/build-angular
? It uses core-js 3 (https://unpkg.com/@angular-devkit/build-angular@0.800.2/package.json), but the error you reported is about it trying to require a core-js 2 file.
That file now correctly imports core-js 3: https://unpkg.com/@angular-devkit/build-angular@0.800.2/src/angular-cli-files/models/jit-polyfills.js
@nicolo-ribaudo thanks for giving me a guide, I just changed the paths in tcconfig.json
like this
"paths": {
"core-js/es7/reflect": [
"../node_modules/core-js/proposals/reflect-metadata"
],
"core-js/es6/": [
"./node_modules/core-js/es/"
]
},
but now I am facing this, Look like there are more errors in new core-js
build. It's so annoying
Unhandled promise rejection Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
For correct polyfilling, you should load core-js
before Zone.js
.
The first issue is the full duplicate of #412.
Should be resolved. If you will have some more questions - write here.
Specified commit didn't fixed my issue, you can ask about resources which I am trying . that may be helpful for me to track issue.
@mudasserzahid one more time - for resolving your issue, you should load core-js
before Zone.js
, see https://github.com/angular/zone.js/issues/783. What commit are you talking about?
I have tried also changing the order of core-js
and zone.js
in pollyfils.ts
like this
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/** IE10 and IE11 requires the following to support `@angular/animation`. */
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
(window as any).global = window;
/** ALL Firefox browsers require the following to support `@angular/animation`. **/
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/* ngx-charts required polyfill ie11 */
import 'core-js/es7/array';
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
// import 'intl/locale-data/jsonp/en';
// Add global to window, assigning the value of window itself.
(window as any).global = window;
If it didn't help - see where you load another polyfill or one more copy of core-js
after zone.js
- this is what is written in your error message. Anyway, it's not a core-js
issue, you could find more info in the zone.js
issue mentioned above.
ERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'core-js/es7/reflect' in 'F:\JSON\angular-json-crud\src'
Hi,
If it is not too late, just remove the number at the end of 'es' in the path, like 'core-js/es/reflect'. It worked for me.
Everything was working fine, as soon as I updated core-js from "2.4.1" to "^3.2.1" I started to see this error. Update the version was the unique change I did, so this is definitely a core-js bug.
When the package is installed it creates neither node_modules/core-js/es6/ nor node_modules/core-js/es7/ folders, only core-js/es/ is found there.
So when I used import 'core-js/es/reflect'; instead, error message disappeared.
@AnassL please, before adding comments like this read the thread.
For some reason importing core-js/es/reflect
did not work in our case, it resulted in this error:
Unhandled Promise rejection: Can't resolve all parameters for ApplicationModule: (?). ; Zone: <root> ; Task: HTMLDocument.addEventListener:DOMContentLoaded ; Value: Error: Can't resolve all parameters for ApplicationModule: (?).
Only import 'core-js/features/reflect';
worked. Not sure why, but it may help someone.
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 core-js@2.5.7 In my case, with Angular, this works ok.
How to correctly usage this with latest version of core-js without downgrade, is the comment of @andreialecu correct? thanks!
In my case, with Angular 7 and core-js 3.6.4, adding to tsconfig.json
"paths": {
"core-js/es7/reflect": [
"../node_modules/core-js/proposals/reflect-metadata"
]
}
works
This worked for me: just swap out es6 and es7 with features directory
import 'core-js/es6/set => import core-js/features/set
npx yarn add @babel/runtime@>=7 core-js-pure@>=3 by installing this, resolved my issue
Hi here is what I am doing, I have upgraded the
core-js
to3.1.3
. Here is mypackage.json
fileand here is my polyyfills file
but ng is unable to build the source code it is throwing the error, that is confusing
Can someone help me in?