Angular-calendar: Recent upgrade to angular v10 spots cyclic dependencies in Date Adapter #1284

Created on 25 Jun 2020  路  8Comments  路  Source: mattlewis92/angular-calendar

Describe the bug

As per title I found this error after upgrading to Angular v10.

Uncaught (in promise): Error: Cannot instantiate cyclic dependency! DateAdapter Error: Cannot instantiate cyclic dependency! DateAdapter at throwCyclicDependencyError (http://localhost:4200/vendor.js:70412:11) at R3Injector.hydrate (http://localhost:4200/vendor.js:76317:13) at R3Injector.get (http://localhost:4200/vendor.js:76143:33) at NgModuleRef$1.get (http://localhost:4200/vendor.js:89037:33) at Object.get (http://localhost:4200/vendor.js:87293:35) at getOrCreateInjectable (http://localhost:4200/vendor.js:68854:39) at Module.傻傻directiveInject (http://localhost:4200/vendor.js:78825:12) at NodeInjectorFactory.CalendarNextViewDirective_Factory [as factory] (http://localhost:4200/vendor.js:138405:189) at getNodeInjectable (http://localhost:4200/vendor.js:68962:44) at instantiateAllDirectives (http://localhost:4200/vendor.js:73077:27) Error: Uncaught (in promise): Error: Cannot instantiate cyclic dependency! DateAdapter Error: Cannot instantiate cyclic dependency! DateAdapter at throwCyclicDependencyError (http://localhost:4200/vendor.js:70412:11) at R3Injector.hydrate (http://localhost:4200/vendor.js:76317:13) at R3Injector.get (http://localhost:4200/vendor.js:76143:33) at NgModuleRef$1.get (http://localhost:4200/vendor.js:89037:33) at Object.get (http://localhost:4200/vendor.js:87293:35) at getOrCreateInjectable (http://localhost:4200/vendor.js:68854:39) at Module.傻傻directiveInject (http://localhost:4200/vendor.js:78825:12) at NodeInjectorFactory.CalendarNextViewDirective_Factory [as factory] (http://localhost:4200/vendor.js:138405:189) at getNodeInjectable (http://localhost:4200/vendor.js:68962:44) at instantiateAllDirectives (http://localhost:4200/vendor.js:73077:27) at resolvePromise (http://localhost:4200/polyfills.js:3904:39) at resolvePromise (http://localhost:4200/polyfills.js:3856:21) at http://localhost:4200/polyfills.js:3966:21 at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:3505:35) at Object.onInvokeTask (http://localhost:4200/vendor.js:92230:33) at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:3504:40) at Zone.runTask (http://localhost:4200/polyfills.js:3273:51) at drainMicroTaskQueue (http://localhost:4200/polyfills.js:3675:39) at ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:3590:25) at invokeTask(http://localhost:4200/polyfills.js:4727:18)
Minimal reproduction of the problem with instructions

not need

Screenshots

not need
Versions

  • @angular/core: 10.0.0
  • angular-calendar: 0.28.16
  • Browser name and version: any

Most helpful comment

As per this comment, the deduping seems to be caused by the date-fns module in /date-adapters not having name or version.
Simply adding some dummy name to the package.json file fixes this, eg:

(date-adapters/date-fns/package.json)

{
  "main": "./index.js",
  "typings": "./index.d.ts",
  "name": "not-date-fns"
}

All 8 comments

Thanks so much for opening an issue! If you'd like me to give priority to answering your issue or would just like to support this project, then please consider sponsoring me

Hey there, sorry to hear you're having issues, the problem is a bug with the angular cli itself (https://github.com/angular/angular-cli/issues/17967) and there is a fix in the works. Unfortunately you'll have to wait until 10.0.1 of the angular cli is released (sometime next week probably). Leaving open for visibility until then 馃槃

Thank you @mattlewis92 I've subscribed to the issue you mentioned and let you know the status of this once tested

As per this comment, the deduping seems to be caused by the date-fns module in /date-adapters not having name or version.
Simply adding some dummy name to the package.json file fixes this, eg:

(date-adapters/date-fns/package.json)

{
  "main": "./index.js",
  "typings": "./index.d.ts",
  "name": "not-date-fns"
}

There used to be a name in the package.json but it caused issues so I had to remove it: https://github.com/mattlewis92/calendar-utils/issues/25 10.0.1 of the angular cli should be released either today or tomorrow so the problem will fix itself then anyway 馃槃

same problem with the following dependencies:

  "dependencies": {
    "@angular/animations": "^10.0.2",
    "@angular/cdk": "10.0.1",
    "@angular/common": "10.0.2",
    "@angular/compiler": "^10.0.2",
    "@angular/core": "^10.0.2",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "^10.0.2",
    "@angular/localize": "^10.0.2",
    "@angular/material": "10.0.1",
    "@angular/material-moment-adapter": "10.0.1",
    "@angular/platform-browser": "^10.0.2",
    "@angular/platform-browser-dynamic": "^10.0.2",
    "@angular/platform-server": "^10.0.2",
    "@angular/pwa": "0.901.7",
    "@angular/router": "^10.0.2",
    "@angular/service-worker": "^10.0.2",
    "@azure/storage-blob": "^10.3.0",
    "@azure/storage-file-share": "12.1.1",
    "@kolkov/angular-editor": "1.1.2",
    "@microsoft/signalr": "3.1.4",
    "@ng-bootstrap/ng-bootstrap": "6.1.0",
    "angular-calendar": "^0.28.16",
    "angularx-flatpickr": "6.3.1",
    "angularx-social-login": "^2.3.1",
    "concurrently": "5.2.0",
    "core-js": "3.6.5",
    "date-fns": "2.14.0",
    "flatpickr": "4.6.3",
    "json-formatter-js": "2.3.4",
    "json2csv": "^5.0.1",
    "jsondiffpatch": "0.4.1",
    "moment": "2.26.0",
    "mustache": "4.0.1",
    "ng-animate": "^0.3.4",
    "ng2-canvas-whiteboard": "3.1.1",
    "ngx-img-cropper": "9.0.1",
    "platform": "^1.3.5",
    "readable-stream": "3.6.0",
    "reflect-metadata": "0.1.13",
    "rimraf": "3.0.2",
    "roboto-fontface": "^0.10.0",
    "rxjs": "6.5.5",
    "uuid": "8.1.0",
    "zone.js": "0.10.3"
  },

And 0.29.0-beta.3 triggers the same.

And the workaround suggested by @tveskag is working. I would look forward to upcoming fix.

Version 10.0.1 of the angular cli was released yesterday which should fix this issue, thanks for your patience! 鉂わ笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chaouiy picture chaouiy  路  3Comments

Seb69 picture Seb69  路  3Comments

Sushma-tiwari picture Sushma-tiwari  路  3Comments

PrasannaKolla picture PrasannaKolla  路  4Comments

AstRonin picture AstRonin  路  4Comments