Error in Angular ng serve static ɵfac: i0.ɵɵFactoryDef<ShepherdService>

Viewed 23033

I had to install a project in another pc, I use Angular v 9.1.0 but after I run npm install I have this error:

ERROR in node_modules/angular-shepherd/lib/shepherd.service.d.ts:64:18 - error TS2314: Generic type 'ɵɵFactoryDef' requires 2 type argument(s).

64 static ɵfac: i0.ɵɵFactoryDef;

I have the same version of the package in both pc angular-shepherd": "^0.5.0

I already tried to remove and reinstall node_modules and also the package angular-shepherd but I still have the error. In the old pc, all works well. If it helps this is the package:

"dependencies": {
    "@angular/animations": "^9.1.0",
    "@angular/cdk": "^9.1.0",
    "@angular/common": "^9.1.0",
    "@angular/compiler": "^9.1.0",
    "@angular/core": "^9.1.0",
    "@angular/forms": "^9.1.0",
    "@angular/material": "^9.1.0",
    "@angular/material-moment-adapter": "^9.1.0",
    "@angular/platform-browser": "^9.1.0",
    "@angular/platform-browser-dynamic": "^9.1.0",
    "@angular/platform-server": "^9.1.0",
    "@angular/router": "^9.1.0",
    "@angular/service-worker": "^9.1.0",
    "@auth0/angular-jwt": "^3.0.1",
    "@fullcalendar/angular": "^4.4.5-beta",
    "@ngx-translate/core": "12.1.2",
    "@ngx-translate/http-loader": "4.0.0",
    "angular-shepherd": "^0.5.0",
    "animate.css": "3.7.2",
    "bootstrap": "4.4.1",
    "chart.js": "^2.9.3",
    "core-js": "^3.6.4",
    "font-awesome": "^4.7.0",
    "google-libphonenumber": "^3.2.7",
    "i18n-iso-countries": "^5.1.0",
    "intl-tel-input": "^16.0.11",
    "jquery": "^3.4.1",
    "jsbarcode": "^3.11.0",
    "latinize": "^0.4.0",
    "material-community-components": "^6.0.0",
    "moment": "^2.24.0",
    "moment-timezone": "0.5.28",
    "net": "^1.0.2",
    "ng2-ckeditor": "^1.2.7",
    "ng2-password-strength-bar": "^1.2.3",
    "ng2-tel-input": "2.3.0",
    "ngx-barcode6": "^1.0.10",
    "ngx-cookie-service": "^3.0.3",
    "ngx-daterangepicker-material": "^2.2.0",
    "ngx-device-detector": "latest",
    "ngx-highlightjs": "^4.0.2",
    "ngx-image-zoom": "^0.6.0",
    "ngx-infinite-scroll": "^8.0.1",
    "ngx-loading": "^8.0.0",
    "node-sass": "^4.13.1",
    "placeholder-loading": "^0.2.5",
    "popper.js": "^1.16.1",
    "primeicons": "^2.0.0",
    "primeng": "^9.0.0",
    "print-js": "^1.0.63",
    "rxjs": "^6.5.4",
    "stompjs": "^2.3.3",
    "stream": "0.0.2",
    "timers": "^0.1.1",
    "tslib": "^1.10.0",
    "url-search-params-polyfill": "^8.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.0",
    "@angular/cli": "^9.1.0",
    "@angular/compiler-cli": "^9.1.0",
    "@types/bootstrap": "4.3.2",
    "@types/chartist": "0.9.48",
    "@types/jasmine": "3.5.10",
    "@types/jquery": "3.3.34",
    "@types/node": "^13.9.5",
    "@types/xml2js": "^0.4.5",
    "codelyzer": "^5.2.1",
    "concurrently": "^5.1.0",
    "cypress": "^4.1.0",
    "cypress-plugin-tab": "^1.0.5",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "^2.1.1",
    "karma-jasmine": "~3.1.1",
    "karma-jasmine-html-reporter": "^1.5.2",
    "lite-server": "^2.5.4",
    "protractor": "^5.4.3",
    "ts-node": "~8.8.1",
    "tslint": "6.1.0",
    "typescript": "3.8.3"
  }
2 Answers

I was having this error today as well. My issue was the version of "@angular/compiler-cli" in my main project was 9.1, but in the library I was importing (it was a local node module), it was using 9.0. I updated the library to use 9.1 and that fixed it for me.

In your case, looks like this is running an older version of the compiler, so you might have to change the version in your project so that they match. Hope this helps!

It is due to the upgrade to angular 9.1. When updating to 9.1, ngcc doesn't seem to handle the conversion well. Remove the lib and reinstall it, it should fix the issue

Related