mezoistvan / ng2-flatpickr

Angular 2+ wrapper for flatpickr (https://github.com/chmln/flatpickr)
100 stars 53 forks source link

Angular Universal #102

Open CrackerakiUA opened 3 years ago

CrackerakiUA commented 3 years ago

Describe the bug javascript global variable is not available on node.js and used within core plugin.

Reproduction just start new angular universal project and put flatpickr on the page

Expected behavior no errors

ReferenceError: navigator is not defined
    at CoreService.ios (C:\dist\bookety\server\main.js:209548:20)
    at new CoreService (C:\dist\bookety\server\main.js:209508:23)
    at Object.CoreService_Factory [as factory] (C:\dist\bookety\server\main.js:209846:61)
    at R3Injector.hydrate (C:\dist\bookety\server\main.js:123895:35)
    at R3Injector.get (C:\dist\bookety\server\main.js:123717:33)
    at NgModuleRef$1.get (C:\dist\bookety\server\main.js:136849:33)
    at R3Injector.get (C:\dist\bookety\server\main.js:123728:33)
    at injectInjectorOnly (C:\dist\bookety\server\main.js:113505:33)
    at Module.ɵɵinject (C:\dist\bookety\server\main.js:113509:57)
    at Object.MetaService_Factory [as factory] (C:\dist\bookety\server\main.js:210004:370)
    at resolvePromise (C:\dist\bookety\server\main.js:105276:39)
    at resolvePromise (C:\dist\bookety\server\main.js:105228:21)
    at C:\dist\bookety\server\main.js:105338:21
    at ZoneDelegate.crGB.ZoneDelegate.invokeTask (C:\dist\bookety\server\main.js:104865:35)
    at Object.onInvokeTask (C:\dist\bookety\server\main.js:140080:33)
    at ZoneDelegate.crGB.ZoneDelegate.invokeTask (C:\dist\bookety\server\main.js:104864:40)
    at Zone.crGB.Zone.runTask (C:\dist\bookety\server\main.js:104632:51)
    at drainMicroTaskQueue (C:\dist\bookety\server\main.js:105045:39)
    at crGB.ZoneTask.invokeTask (C:\dist\bookety\server\main.js:104951:25)
    at Server.ZoneTask.invoke (C:\dist\bookety\server\main.js:104936:52) {
  rejection: ReferenceError: navigator is not defined
      at CoreService.ios (C:\dist\bookety\server\main.js:209548:20)
      at new CoreService (C:\dist\bookety\server\main.js:209508:23)
      at Object.CoreService_Factory [as factory] (C:\dist\bookety\server\main.js:209846:61)
      at R3Injector.hydrate (C:\dist\bookety\server\main.js:123895:35)
      at R3Injector.get (C:\dist\bookety\server\main.js:123717:33)
      at NgModuleRef$1.get (C:\dist\bookety\server\main.js:136849:33)
      at R3Injector.get (C:\dist\bookety\server\main.js:123728:33)
      at injectInjectorOnly (C:\dist\bookety\server\main.js:113505:33)
      at Module.ɵɵinject (C:\dist\bookety\server\main.js:113509:57)
      at Object.MetaService_Factory [as factory] (C:\dist\bookety\server\main.js:210004:370),
  promise: ZoneAwarePromise [Promise] {
    __zone_symbol__state: 0,
    __zone_symbol__value: ReferenceError: navigator is not defined
        at CoreService.ios (C:\dist\bookety\server\main.js:209548:20)
        at new CoreService (C:\dist\bookety\server\main.js:209508:23)
        at Object.CoreService_Factory [as factory] (C:\dist\bookety\server\main.js:209846:61)
        at R3Injector.hydrate (C:\dist\bookety\server\main.js:123895:35)
        at R3Injector.get (C:\dist\bookety\server\main.js:123717:33)
        at NgModuleRef$1.get (C:\dist\bookety\server\main.js:136849:33)
        at R3Injector.get (C:\dist\bookety\server\main.js:123728:33)
        at injectInjectorOnly (C:\dist\bookety\server\main.js:113505:33)
        at Module.ɵɵinject (C:\dist\bookety\server\main.js:113509:57)
        at Object.MetaService_Factory [as factory] (C:\dist\bookety\server\main.js:210004:370)
  },
  zone: Zone {
    _parent: Zone {
      _parent: null,
      _name: '<root>',
      _properties: {},
      _zoneDelegate: [ZoneDelegate]
    },
    _name: 'angular',
    _properties: { isAngularZone: true, maybeDelayChangeDetection: false },
    _zoneDelegate: ZoneDelegate {
      _taskCounts: [Object],
      zone: [Circular],
      _parentDelegate: [ZoneDelegate],
      _forkZS: null,
      _forkDlgt: null,
      _forkCurrZone: null,
      _interceptZS: null,
      _interceptDlgt: null,
      _interceptCurrZone: null,
      _invokeZS: [Object],
      _invokeDlgt: [ZoneDelegate],
      _invokeCurrZone: [Circular],
      _handleErrorZS: [Object],
      _handleErrorDlgt: [ZoneDelegate],
      _handleErrorCurrZone: [Circular],
      _scheduleTaskZS: [Object],
      _scheduleTaskDlgt: [ZoneDelegate],
      _scheduleTaskCurrZone: [Circular],
      _invokeTaskZS: [Object],
      _invokeTaskDlgt: [ZoneDelegate],
      _invokeTaskCurrZone: [Circular],
      _cancelTaskZS: [Object],
      _cancelTaskDlgt: [ZoneDelegate],
      _cancelTaskCurrZone: [Circular],
      _hasTaskZS: [Object],
      _hasTaskDlgt: [ZoneDelegate],
      _hasTaskDlgtOwner: [Circular],
      _hasTaskCurrZone: [Circular]
    }
  },
  task: ZoneTask {
    _zone: Zone {
      _parent: [Zone],
      _name: 'angular',
      _properties: [Object],
      _zoneDelegate: [ZoneDelegate]
    },
    runCount: 0,
    _zoneDelegates: null,
    _state: 'notScheduled',
    type: 'microTask',
    source: 'Promise.then',
    data: ZoneAwarePromise [Promise] {
      __zone_symbol__state: 0,
      __zone_symbol__value: ReferenceError: navigator is not defined
          at CoreService.ios (C:\dist\bookety\server\main.js:209548:20)
          at new CoreService (C:\dist\bookety\server\main.js:209508:23)
          at Object.CoreService_Factory [as factory] (C:\dist\bookety\server\main.js:209846:61)
          at R3Injector.hydrate (C:\dist\bookety\server\main.js:123895:35)
          at R3Injector.get (C:\dist\bookety\server\main.js:123717:33)
          at NgModuleRef$1.get (C:\dist\bookety\server\main.js:136849:33)
          at R3Injector.get (C:\dist\bookety\server\main.js:123728:33)
          at injectInjectorOnly (C:\dist\bookety\server\main.js:113505:33)
          at Module.ɵɵinject (C:\dist\bookety\server\main.js:113509:57)
          at Object.MetaService_Factory [as factory] (C:\dist\bookety\server\main.js:210004:370)
    },
    scheduleFn: undefined,
    cancelFn: undefined,
    callback: [Function],
    invoke: [Function]
  }
}
CrackerakiUA commented 3 years ago

Workaround is definitely to not show flatpickr on Angular Universal, feel free to close the issue, just wanted you to know about this.