112

Im getting like 50 errors that all say that angular/core/core has no exported member 'eeFactoryDef'.

They come from different node_modules, for example angular/cdk, ng-bootstrap, ngx-pipes, ng2-dragula and some more. I didn't find anything from google either.

../node_modules/@angular/cdk/drag-drop/typings/directives/drag-handle.d.ts:23:33 - error TS2694: Namespace '"/Users/heikopiirme/Documents/realNewClient/client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.

23     static ngFactoryDef: ɵngcc0.ɵɵFactoryDef<CdkDragHandle>;

This is my package.json file:

Here are my depencencies:

    "@angular-skyhook/core": "^1.1.1",
    "@angular-skyhook/multi-backend": "^1.1.1",
    "@angular/animations": "^8.2.6",
    "@angular/cdk": "^8.2.0",
    "@angular/common": "^8.2.6",
    "@angular/compiler": "^8.2.6",
    "@angular/core": "^8.2.6",
    "@angular/forms": "^8.2.6",
    "@angular/http": "^7.1.4",
    "@angular/material": "^8.2.0",
    "@angular/platform-browser": "^8.2.6",
    "@angular/platform-browser-dynamic": "^8.2.6",
    "@angular/router": "^8.2.6",
    "@ng-bootstrap/ng-bootstrap": "^5.1.1",
    "@ng-select/ng-select": "^3.0.7",
    "@swimlane/ngx-datatable": "^13.1.0",
    "@types/googlemaps": "^3.36.5",
    "angular2-draggable": "^2.3.1",
    "bootstrap": "^4.2.1",
    "core-js": "^2.6.1",
    "drag-drop-webkit-mobile": "^1.4.1",
    "exif-js": "^2.3.0",
    "hammerjs": "^2.0.8",
    "mobile-drag-drop": "^2.3.0-rc.2",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "net": "^1.0.2",
    "ng2-dnd": "^5.0.2",
    "ng2-dragula": "^2.1.1",
    "ng2-file-upload": "^1.3.0",
    "ng2-img-max": "^2.1.18",
    "ngx-bar-rating": "^1.1.0",
    "ngx-bootstrap": "^4.3.0",
    "ngx-material-timepicker": "^5.1.0",
    "ngx-permissions": "^5.0.0",
    "ngx-pipes": "2.5.6",
    "ngx-toastr": "^10.0.4",
    "react-dnd-html5-backend": "^7.6.0",
    "rxjs": "^6.5.3",
    "sockjs-client": "^1.3.0",
    "stompjs": "^2.3.3",
    "touchscreen-dnd-shim": "^1.2.2",
    "underscore": "^1.9.1",
    "zone.js": "~0.9.1"

And here are my dev dependencies:

"@angular-devkit/build-angular": "^0.803.4",
    "@angular/cli": "~8.3.4",
    "@angular/compiler-cli": "^8.2.6",
    "@angular/language-service": "^8.2.6",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^8.9.5",
    "codelyzer": "~5.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.12.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  }

Couldn't find any information on google for some reason.

eixcs
  • 1,957
  • 4
  • 15
  • 37
  • Solved it by upgrading angular from v11 to v12 with guidance from the angular upgrade documentation – D. Sackey Sep 09 '21 at 00:07
  • 1
    If you're thinking about answering this question, **PLEASE** don't say you solved this problem by upgrading/downgrading package x or y. This answer will be highly specific to that package and of limited use to most people. Upgrading/downgrading is just a [symptom of the underlying problem](https://stackoverflow.com/a/72186353/542251) – Liam Aug 09 '22 at 08:01

18 Answers18

129

I ran into this after updating some packages (including Angular from 8 to 9), then downgrading again.

The solution was to nuke the node_modules folder and then do a fresh npm install.

peregrination
  • 2,460
  • 1
  • 25
  • 21
  • 4
    After so many users and being the 'leading standard' package manager, how can npm still have issues like this... – SDekov Mar 03 '20 at 11:20
  • @SDekov: Not an NPM issue. It's a Angular upgrade issue. If you had changed your package.json to point to Angular 9 version libraries and had run npm install, it makes sense to nuke node_modules and reinstall with downgraded version. – Anjil Dhamala Feb 18 '21 at 18:36
  • 5
    I got this on Angular 12 after having to adjust a custom webpack config due to some other projects that had polyfill issues. I attempted to delete node_modules but its still showing ooFactoryDef, ooNgModuleDefWithMeta errors. Starting to wonder if its node or npm version issues or something else. – Mark May 18 '21 at 14:48
  • Does `npm ci` accomplish the same thing? – mlhDev Jul 16 '21 at 15:47
  • 3
    Same error after npm ci, and deleting node_modules, is there anotgher solition, these 'solutions' are a copy paste of the same tjing – fsalazar_sch Mar 07 '22 at 15:39
30

A lot of people saying the solution here is to simply "delete your node_modules". This may or may not work.


To understand why that is the case, you need to understand why you're getting this error. This is caused by a breaking change in Angular where code generated using angular version x is not compatible with angular version y (happens in multiple versions, I'm currently getting it between 10 and 13). The eeFactoryDef is a method generated by Angular when your source is compiled. The name of this method has changed over the years. So the delete node_modules works because it's assuming that you've just upgraded angular and you have an old version still hanging about.

This also explains why there are so many different answers to this question. The angular incompatibility could be in your code or one of its dependancies. All the people saying "I get this in x library" are basically because of this underlying problem.


But, you can also get this issue if you have a dependency issue. The easiest way to diagnose this problem is to run npm ls @angular/core. This will list all the library dependencies that link to this lib, for example I get:

`-- UNMET PEER DEPENDENCY @angular/core@13.2.5

npm ERR! peer dep missing: @angular/core@~11.2.13, required by blah@2.1.1
npm ERR! peer dep missing: @angular/core@12.2.15, required by blah@13.0.4
npm ERR! peer dep missing: @angular/core@^11.0.5, required by blah@11.0.5
npm ERR! peer dep missing: @angular/core@^6.0.0 || ^7.0.0 || ^8.0.0, required by ngx-avatar@3.7.0

In this scenario you need to upgrade the conflicting libraries so that they all use the same (or a compatible) version of angular (and no amount of deleting and re-adding of node_modules will make any difference).


Another problem that has this as a symptom is the Ivy compiler. Again, this can produce an incompatible build between libraries and applications. The solution here depends on where the incompatibility lies. If you lib is not Ivy but your application is, then you can either opt out of Ivy (note this is now disabled in Angular 12)

tsconfig.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ],
  "angularCompilerOptions": {
    "enableIvy": false
  }
}

Or run ngcc in a postinstall event:

package.json

{
   "scripts": {
       "postinstall": "ngcc"
   }
}
Liam
  • 27,717
  • 28
  • 128
  • 190
  • 1
    You cannot opt-out of Ivy if your project is running Angular 12 or higher. I got this message. "The project is attempting to disable the Ivy compiler. Angular versions 12 and higher do not support the deprecated View Engine compiler for applications. The Ivy compiler will be used to build this project." – Animesh Rawat Sep 07 '22 at 17:30
24

I'm getting the same error. I'm using Angular 9.7.1, I first tried to delete the node_modules and npm install but it didn't work so I finally fixed it adding this to the tsconfig.json:

"compilerOptions":{
 [...]
 "paths": {
      "@angular/*": ["./node_modules/@angular/*"]
    }
}
Alvaro Estrada
  • 273
  • 2
  • 3
  • 4
    @Alvaro can you explain why this fix the issue Thanks – Oliamster Dec 11 '21 at 15:52
  • 1
    @Alvaro this is not working for me. – GKhedekar Apr 04 '22 at 04:00
  • This is not working for me unforunately. – David R Jun 15 '22 at 09:31
  • weirdly this is working for me on Windows when compiling angular 13 on node 16, it used to work just fine but then suddenly not, I added this and now it does. If I were to take a guess I think it may have been a configuration change on my computer meant that when ng built it couldn't find the right angular dep and instead maybe used the global one which would result in ivy errors since the partially built deps wouldn't exist there – Sammaye Jul 28 '22 at 09:42
18

In addition to the reasons/solutions previously shared, another reason this could happen is if npm packages are incompatible with your current Angular version.

For example, I got these after running npm i primeng. NPM installed the most recent version (v12), but I was only running ng11.

In my case, the solution was to upgrade Angular, but another solution would be to downgrade the npm package.

rgahan
  • 667
  • 8
  • 17
  • 4
    I had this problem with primeng. The problem seems to be that the package.json file in primeng's node_modules says that it works with old versions of angular, but it doesn't. – Bruce Jul 31 '21 at 08:00
  • This was the case for me. I was following an Angular tutorial, where we needed ngx-toastr. The tutorial used angular cli 9, so I made sure to use that, but when I added toastr, the new versions was not compatible with Angular 9. I wish their was a clearer error message suggesting this might be the issue. Downgrading ngx-toastr ended up fixing the problem. – ANimator120 Jan 24 '23 at 23:58
4

I run ino the same issue when trying to upgrade to Angular 10 in another feature branch.

it messed up 'node_modules' folder.

Solution:

run npm ci.

Langy
  • 315
  • 2
  • 6
3

In my case, it was being caused by ngx-toastr. After much of hit and trial, solved using below approach:

  1. First checked the version of angular using command ng version.
  2. Visited https://www.npmjs.com/package/ngx-toastr and check the toastr version suitable for my angular version.
  3. Installed the suitable version of toastr.
3

I was recently having similar issue with ng-lazyload-image plugin.

We were using Angular 9 and in our package.json we were calling "ng-lazyload-image": "^9.1.0"

I changed it to "ng-lazyload-image": "9.1.0" and the build started to work in Jenkins.

Posting it here to help someone, facing the same issue with this plugin.

2

I got the issue when switching between Angular 8 and 9 multiple times as mentioned by peregrination.

Solution for me was not to delete "node_module" and run "npm install" again, but to remove and re-install npm packages to angular 8 compatible version which were mentioned in the error.

ERROR in node_modules/ngx-infinite-scroll/src/modules/infinite-scroll.directive.d.ts:27:25 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.
27     static ɵfac: ɵngcc0.ɵɵFactoryDef<InfiniteScrollDirective, never>;
                           ~~~~~~~~~~~~
node_modules/ng-click-outside/lib_commonjs/click-outside.directive.d.ts:34:25 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.
34     static ɵfac: ɵngcc0.ɵɵFactoryDef<ClickOutsideDirective, never>;
Saad Khan
  • 109
  • 1
  • 4
2

Note that this might be a compatibility issue with one of your libraries. E.g: the library expects you to have Angular 12, but your project runs Angular 11 instead. Take a look at the library's package.json history and check if it is using a greater Angular version indeed. If it is, then you'll have two options:

  1. Upgrade your Angular version to be the same as the library's
  2. Downgrade the library version back to when it used the same Angular version as yours (might not be possible if the library never used that Angular version)
Allan Juan
  • 2,048
  • 1
  • 18
  • 42
  • Is there a way to check the compatible version of a library with angular? – Rahul Feb 01 '23 at 12:45
  • 1
    Visit the library's repository on GitHub and check their `package.json` file to find out what Angular version they're using. – Allan Juan Feb 01 '23 at 13:47
2

I hit this issue today after updating project to Angular 12 on feature branch then switching branch back to main which was still Angular 10. In addition I noticed the error Another process, with id 95467, is currently running ngcc. which proceeded the x was not found in @angular/core errors. But I didn't have any other install / build / serve tasks running.

After running the following commands this issue was fixed:

npm ci
ng update

Suggestion was to update @angular/core and @angular/cli from 12.2.9 -> 12.2.10 so I ran:

ng update @angular/core @angular/cli

Then was able to run npm start to run Angular 12 app ok

David Douglas
  • 10,377
  • 2
  • 55
  • 53
2

I faced the same problem when I was trying to integrate ngx-mask package.

Reason For Issue : angular version was 9.0.1 and ngx-mask version was higher

Solution : I downgraded the ngx-mask version to 9.0.1 which was compatible with my angular version

Prasad Shetty
  • 115
  • 1
  • 5
1

This error can happen if you have a project using Angular 12, that depends on a library built prior to Angular 12.

You will have to have the library catch up to Angular 12 to resolve the issue.

Eric E AT MT
  • 379
  • 3
  • 6
0

Main project had Angular 8 and I got this issue when some packages with Angular 9 were installed. Use this for upgrade steps: https://update.angular.io - specifically upgrade to latest version of 8 ng update @angular/core@8 @angular/cli@8 then to 9 ng update @angular/core@9 @angular/cli@9.

Matjaz Hirsman
  • 326
  • 3
  • 9
0

This issue also comes up when we install a libraray to our project and the fix for it is, must check the version compatibility of the library with the angular version you have.

0

I installed ngx-indexed-db and I was having this error Ng serve throwing @angular/core/core has no exported member for me it was purely a version based error I solved it by downgrading the library using this command

npm i ngx-indexed-db@9.1.0

Chameleon
  • 149
  • 2
  • 8
0

Quick solution - check the Angular version in your package.json, then make sure that the Angular CLI matching version is installed globally to NPM.

E.g. if you have Angular 10.2.4 installed in your project, make sure to also add that specific Angular CLI globally by doing:

npm install -g @angular/cli@10.2.4
Coruscate5
  • 2,253
  • 17
  • 28
-1

ng update @angular/cli @angular/core --allow-dirty

it works for me.

Kaushik
  • 29
  • 6
-3

Delete folder node_modules then run the npm i command

Aman Gojariya
  • 1,289
  • 1
  • 9
  • 21
Mojtaba Nava
  • 858
  • 7
  • 17