Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 'ERROR in ./src/polyfills.ts' while running `ng build --prod`

Tags:

angular

I have setup Angular 6 project. I am trying to run ng build --prod but I am getting below error

Module not found: Error: Can't resolve 'core-js/es7/reflect' in 'c:\localpath'

I am getting this error Angular 6 CLI version.

like image 904
Sandy Sanap Avatar asked Jan 28 '26 15:01

Sandy Sanap


2 Answers

I think you got this error because you are using -aot compiler.

What you need here is open the polyfill.ts and comment the import 'core-js/es7/reflect'.

/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
//import 'core-js/es7/reflect';

Hope this will help

like image 197
TheParam Avatar answered Jan 30 '26 05:01

TheParam


You can change 'es7' to 'es' as mentioned here, for me this worked:

import 'core-js/es/reflect';

But then I got

Error: Can't resolve 'core-js/es/global'

Then I noticed the version of my core-js was different from the one in the project, so I installed the specific version of core-js needed:

npm install --save core-js@^2.5.0

Hope one of these will solve your problem.

like image 30
MSoutto Avatar answered Jan 30 '26 04:01

MSoutto