date-holidays icon indicating copy to clipboard operation
date-holidays copied to clipboard

TypeError: Cannot convert undefined or null to object

Open SSANSH opened this issue 3 years ago • 9 comments

var Holidays = require('date-holidays')
// or using a new instance
hd = new Holidays('JP');
console.log(hd.getHolidays(2020));

Following codes failed on lastest version of [email protected] . its works with the version "[email protected]", do you know why?

/node_modules/astronomia/lib/planetposition.cjs:19
  Object.keys(series).forEach((x) => {
         ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at sum (/node_modules/astronomia/lib/planetposition.cjs:19:10)
    at Planet.position (/node_modules/astronomia/lib/planetposition.cjs:96:38)
    at trueVSOP87 (/node_modules/astronomia/lib/solar.cjs:161:36)
    at Object.apparentVSOP87 (/node_modules/astronomia/lib/solar.cjs:189:29)
    at eq2 (/node_modules/astronomia/lib/solstice.cjs:255:32)
    at longitude (/node_modules/astronomia/lib/solstice.cjs:238:10)
    at Object.march2 (/node_modules/astronomia/lib/solstice.cjs:162:10)
    at Equinox.inYear (/node_modules/date-holidays-parser/lib/Equinox.cjs:29:35)
    at /node_modules/date-holidays-parser/lib/DateFn.cjs:43:12

SSANSH avatar Dec 12 '22 15:12 SSANSH

` 12845a12846,12868

    "march equinox in +09:00": {
      "name": {
        "en": "Spring Equinox Day",
        "jp": "春分の日"
      },
      "active": [
        {
          "from": "1948-07-20T00:00:00.000Z"
        }
      ]
    },
    "substitutes march equinox in +09:00 and if sunday then next monday": {
      "substitute": true,
      "name": {
        "en": "Spring Equinox Day",
        "jp": "春分の日"
      },
      "active": [
        {
          "from": "1973-04-12T00:00:00.000Z"
        }
      ]
    },

13100a13124,13146

    },
    "september equinox in +09:00": {
      "name": {
        "en": "Autumnal Equinox Day",
        "jp": "秋分の日"
      },
      "active": [
        {
          "from": "1948-07-20T00:00:00.000Z"
        }
      ]
    },
    "substitutes september equinox in +09:00 and if sunday then next monday": {
      "substitute": true,
      "name": {
        "en": "Autumnal Equinox Day",
        "jp": "秋分の日"
      },
      "active": [
        {
          "from": "1973-04-12T00:00:00.000Z"
        }
      ]

` all this code is not cover by test and don't work.

SSANSH avatar Dec 12 '22 16:12 SSANSH

Had this same issue attempting to generate 2022 holidays for both Japan and Taiwan, but it appears to be date-dependent, was a problem on Dec. 7th but seems fine today, same version (3.14.2).

aradnom avatar Dec 12 '22 16:12 aradnom

I try with 2022 and its doesnt work today on my side, something is broken with date-holidays-parser and then astronomia packages.

SSANSH avatar Dec 12 '22 16:12 SSANSH

Please find a sample project at https://github.com/commenthol/date-holidays-example which proves that the module is usable either as ESM or commonJS module. I suspect that the issue is related to your project setup. Please feel free to share a sample project which demonstrates your experienced issues.

commenthol avatar Dec 12 '22 18:12 commenthol

I now can confirm the issue. I oversaw that it only occurs with equinox dates. This was introduced by updating to rollup ^3 in date-holidays-parser. For the moment please add npm i [email protected] to your project, this will downgrade the parser. Will see how to provide a fix here.

commenthol avatar Dec 13 '22 06:12 commenthol

Hi, Thanks for your sample project but my exemple was already a sample project, so I don't need this and I confirm this not come from my sampe project :) . moreover yes I have the same result as you (see thread number two), rules are all with equinox and I have the same suspect date-holidays-parser. So Yes I will downgrade the parser as you suggest, and then I will wait for a fix.

SSANSH avatar Dec 13 '22 06:12 SSANSH

Hi @SSANSH, [email protected] reverts back to rollup@2 Can you please give it a try with this downgraded version?

commenthol avatar Dec 13 '22 07:12 commenthol

@commenthol I tried with npm i [email protected] and it doesnt work in fact. I have the same ussue, sorry for the previous bad answer.

SSANSH avatar Dec 13 '22 08:12 SSANSH

@SSANSH Can you please remove all node_modules and your lock file and do a install install? Do not forget to remove the [email protected] line in you package.json. That should work. I'll bump the versions with the next patch.

commenthol avatar Dec 16 '22 08:12 commenthol