Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.0-beta.3 - Can't resolve 'core-js/es7/reflect' #412

Closed
ghost opened this issue Jun 16, 2018 · 12 comments
Closed

3.0.0-beta.3 - Can't resolve 'core-js/es7/reflect' #412

ghost opened this issue Jun 16, 2018 · 12 comments
Labels

Comments

@ghost
Copy link

ghost commented Jun 16, 2018

I'm using @angular/cli I upgraded to the 3.0.0-beta.3 and I'm getting an import error on this import:
import 'core-js/es7/reflect';

@zloirock
Copy link
Owner

Yes, in core-js@3 es7 path removed. Use, for example, core-js/proposals/reflect-metadata.

@dreamweaverz
Copy link

Find the polyfills.ts in src folder and comment the line "import 'core-js/es7/reflect'" as it is not required if using AOT

@dvdmunckhof
Copy link

dvdmunckhof commented Jan 9, 2019

I have the Angular 7 CLI working fine with core-js 3. Work around the incompatibility by adding this to your tsconfig.json file:

{
  "compilerOptions": {
    "paths": {
      "core-js/es7/reflect": [
        "node_modules/core-js/proposals/reflect-metadata"
      ]
    }
  }
}

This works by making the TypeScript compiler resolve core-js/es7/reflect to core-js/proposals/reflect-metadata. No edits in jit-polyfills.js needed.

@Faran52
Copy link

Faran52 commented Mar 20, 2019

I had the same issue as @dvdmunckh but additionally I was receiving multiple es6 issues too, I resolved them by adding one more line
"core-js/es6/*": ["node_modules/core-js/es"],

@prsujoy
Copy link

prsujoy commented Mar 27, 2019

I've roll backed the version of to "core-js": "2.6.5" from"core-js": "3.0.0" and its started working. Below is my package.json.

"dependencies": {
"@angular/animations": "7.2.11",
"@angular/common": "7.2.11",
"@angular/compiler": "7.2.11",
"@angular/core": "7.2.11",
"@angular/forms": "7.2.11",
"@angular/http": "7.2.11",
"@angular/material": "7.3.6",
"@angular/platform-browser": "7.2.11",
"@angular/platform-browser-dynamic": "7.2.11",
"@angular/platform-server": "7.2.11",
"@angular/router": "7.2.11",
"@nguniversal/module-map-ngfactory-loader": "7.1.1",
"ajv": "6.10.0",
"aspnet-prerendering": "3.0.1",
"bootstrap": "4.3.1",
"core-js": "2.6.5",
"devextreme": "18.2.7",
"devextreme-angular": "^18.2.7",
"font-awesome": "4.7.0",
"jquery": "3.3.1",
"popper.js": "1.14.7",
"rxjs": "6.4.0",
"rxjs-compat": "6.4.0",
"stream": "0.0.2",
"web-animations-js": "2.3.1",
"zone.js": "0.9.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.13.6",
"@angular/cli": "7.3.6",
"@angular/compiler-cli": "7.2.11",
"@angular/language-service": "7.2.11",
"@types/jasmine": "3.3.12",
"@types/jasminewd2": "2.0.6",
"@types/node": "11.12.0",
"codelyzer": "4.5.0",
"jasmine-core": "3.3.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "4.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage-istanbul-reporter": "2.0.5",
"karma-jasmine": "2.0.1",
"karma-jasmine-html-reporter": "1.4.0",
"protractor": "6.0.0",
"ts-node": "8.0.3",
"tslint": "5.14.0",
"typescript": "3.2.4",
"webpack-cli": "3.3.0"
},

@godenji
Copy link

godenji commented Apr 7, 2019

Find the polyfills.ts in src folder and comment the line "import 'core-js/es7/reflect'" as it is not required if using AOT

Or just change it to latest core-js path since AOT qualifier applies only if you rely on Angular decorators alone (i.e. none of your dependencies apply their own decorators).

import 'core-js/proposals/reflect-metadata'

@godenji
Copy link

godenji commented Apr 7, 2019

EDIT:
unintuitively (both tsconfig.ts and node_modules are in project root) prefixing the import like "../node_modules/core-js/..." gets the build working.

The compilerOptions paths workaround appears to do nothing as of angular-devkit 0.13.8 and core-js 3.0.1.

Is there a viable workaround short of hacking jit-polyfills.js (brittle) or just giving up and rolling back to core-js 2.x?

@sopedro
Copy link

sopedro commented May 12, 2019

@dvdmunckhof thanks. worked for me.

@Yohandah
Copy link

Yohandah commented May 23, 2019

edit: I'm quite dumb actually, you juste have to import core-js/es/array haha

nb : note that with angular 8 you no longer need to import reflect as it is bundled by default in angular cli


I had an error : Error: Can't resolve 'core-js/es7/array'

Resolved by adding : "core-js/es7/*": ["node_modules/core-js/es"]

resulting in addition with all of the fixes :

"paths": {
      "core-js/es7/reflect": [
        "node_modules/core-js/proposals/reflect-metadata"
      ],
      "core-js/es6/*": ["node_modules/core-js/es"],
      "core-js/es7/*": ["node_modules/core-js/es"]
    }

@akopchinskiy
Copy link

Not working for me.

"paths": {
            "core-js/es7/reflect": [
                "./node_modules/core-js/proposals/reflect-metadata"
            ]
        }
Module not found: Error: Can't resolve 'core-js/es7/reflect'

@plackowski
Copy link

Not working for me, my package.json

"dependencies": {
"@angular/animations": "~8.2.6",
"@angular/common": "~8.2.6",
"@angular/compiler": "~8.2.6",
"@angular/core": "~8.2.6",
"@angular/forms": "~8.2.6",
"@angular/http": "~8.0.0-beta.10",
"@angular/platform-browser": "~8.2.6",
"@angular/platform-browser-dynamic": "~8.2.6",
"@angular/router": "~8.2.6",
"core-js": "^3.2.1",
"nativescript-angular": "~8.2.1",
"nativescript-theme-core": "~2.0.20",
"reflect-metadata": "~0.1.13",
"rxjs": "~6.5.3",
"tns-core-modules": "~6.1.1",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular/cli": "~8.3.4",
"@angular/compiler-cli": "~8.2.6",
"@angular-devkit/build-angular": "~0.803.4",
"@nativescript/schematics": "~0.7.1",
"@nativescript/tslint-rules": "~0.0.4",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.6",
"@types/node": "~12.7.5",
"codelyzer": "^5.1.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"nativescript-dev-webpack": "~1.2.0",
"protractor": "~5.4.2",
"ts-node": "~8.4.1",
"tslint": "~5.20.0",
"typescript": "~3.6.3",
"node-sass": "^4.12.0"
}

my tsconfig
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom", "es6", "es2015.iterable"],
"baseUrl": ".",
"paths": {
"@src/": ["src/.android.ts", "src/.ios.ts", "src/.tns.ts", "src/.web.ts", "src/.ts"],
"core-js/es7/reflect": ["node_modules/core-js/proposals/reflect-metadata"],
"core-js/es6/": ["node_modules/core-js/es"],
"core-js/es7/
": ["node_modules/core-js/es"]
}
}
}

@dvdmunckhof
Copy link

@Arystosedes, this workaround is not needed when using Angular 8, as Angular 8 uses core-js 3 out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants