commenthol / date-holidays

worldwide holidays
https://commenthol.github.io/date-holidays/
Other
935 stars 242 forks source link

Module not found: TypeCannot read properties of undefined (reading 'startsWith') #487

Open bigbizze opened 1 month ago

bigbizze commented 1 month ago
./node_modules/moment/moment.js
Module not found: TypeCannot read properties of undefined (reading 'startsWith')

Import trace for requested module:
./node_modules/moment/moment.js
./node_modules/moment-timezone/moment-timezone.js
./node_modules/moment-timezone/index.js
./node_modules/date-holidays-parser/src/Equinox.js
./node_modules/date-holidays-parser/src/CalEventFactory.js
./node_modules/date-holidays-parser/src/DateFn.js
./node_modules/date-holidays-parser/src/Holidays.js
./node_modules/date-holidays-parser/src/index.js
./node_modules/date-holidays/src/Holidays.js
./node_modules/date-holidays/src/index.js

I am not sure what is causing this issue, I'm assuming it's some dependency thing between date-holidays, date-holidays-parser, moment-timezone and moment.


I have my resolutions set to:

  "resolutions": {
    "date-holidays-parser": "^3.4.4",
    "moment": "^2.29.4",
    "moment-timezone": "0.5.43"
  },

and i am using date-holidays@3.23.12


date-holidays-parser issue: https://github.com/commenthol/date-holidays-parser/issues/59 moment-timezone issue: https://github.com/moment/moment-timezone/issues/1122 moment issue: https://github.com/moment/moment/issues/6259

osterreich commented 1 month ago

Faced similar issue when tried to call destructured method returned from Holidays() constructor:

const { isHoliday } = new Holidays('US');
isHoliday(new Date(value));

Error:

Cannot read properties of undefined (reading '__timezone')
TypeError: Cannot read properties of undefined (reading '__timezone')
    at isHoliday (http://localhost:3000/static/js/bundle.js:424791:31)
    ...

Correct usage:

 const holidays = new Holidays('US');
 holidays.isHoliday(new Date(value));

There might be a binding issue somewhere in date-holidays code I guess.