4
Global Angular CLI: 7.3.8
Node v10.15.3
NPM 6.4.1
macos

I'm getting this error on npm start

ERROR in ./node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/jit-polyfills.js Module not found: Error: Can't resolve 'core-js/es7/reflect' in '/Users/XXX/projects/XXX/node_modules/@angular-devkit/build-angular/src/angular-cli-files/models' ERROR in ./src/polyfills.ts Module not found: Error: Can't resolve 'core-js/es7/reflect' in '/Users/XXX/projects/XXX/src'

Dmitry Grinko
  • 13,806
  • 14
  • 62
  • 86
  • For projects being upgraded to Angular 8 or later, you can uninstall core.js as a dependency: https://stackoverflow.com/questions/56892243/is-not-core-js-needed-anymore – John Gilmer Oct 23 '20 at 07:18
  • @JohnGilmer Thank you for your comment. Feel free to add it as an answer. It will be helpful – Dmitry Grinko Oct 23 '20 at 19:35

5 Answers5

18

To solve this issue I've added the following paths to compilerOptions in tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "paths": {
      "core-js/es7/reflect": [
        "node_modules/core-js/proposals/reflect-metadata",
      ],
      "core-js/es6/*": ["node_modules/core-js/es"]
    },
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }
}
Dmitry Grinko
  • 13,806
  • 14
  • 62
  • 86
5

After Migrated to new Angular version, '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.

Bhadresh Patel
  • 1,671
  • 17
  • 18
2

just remove the number at the end of 'es' in the path, like 'core-js/es/reflect'. It worked for me.

Stanley Mohlala
  • 6,816
  • 1
  • 11
  • 20
0

I just copy all from my oldest project src/polyfills to the new imported. That's help ;) .

0

Getting this error in "@angular/cli": "~10.1.5" project:

Cannot find module 'core-js/es7/reflect' or its corresponding type declarations.ts(2307)

Solution:

import * as Reflect from 'core-js/es';
fcdt
  • 2,371
  • 5
  • 14
  • 26
Pinaki
  • 792
  • 8
  • 17