html2json icon indicating copy to clipboard operation
html2json copied to clipboard

Reference Error: DEBUG is not defined.

Open Anirudh17072000 opened this issue 2 years ago • 4 comments

Currently I am using html2json npm package but it is giving me the error DEBUG is not defined. I am using it for converting html code to json in an angular project.

Screenshot from 2023-04-10 15-25-26

Screenshot from 2023-04-10 15-26-50

Kindly help me out with this issue.

Anirudh17072000 avatar Apr 10 '23 09:04 Anirudh17072000

I am facing the same issue, If you found the fix can you please share it.

akifshah7 avatar Jul 17 '23 07:07 akifshah7

Same issue here, anyone found a fix?

Holt59 avatar Aug 12 '23 18:08 Holt59

Also got that issue. No idea why suddenly. Can't use this package anymore.

mawiswiss avatar Sep 29 '23 03:09 mawiswiss

I got the same problem, at first I decided to patch it with yarn patch, because I think the DEBUG var was not correctly hoisted, for some reason. Maybe the new ES versions treat this differently...last commit on this package was 7 years ago.

So, a very dumb patch (also why I didn't consider submitting a PR lol) :

// DEBUG = false;
// var debug = DEBUG ? console.log.bind(console) : function(){};
const debug = function () {};

But then I faced another problem, this time coming from the integrated HTML parser library (in the lib directory). After a few research, it looks like this library is also quite "old" (2008-2010 probably). Error also comes from something which probably didn't behave that way back in the time.

So in the end, I just decided to migrate to another library : https://www.npmjs.com/package/html-to-json-parser Objects format is different, but migration was pretty easy. Also beware the API is async.

ld-web avatar Dec 20 '23 11:12 ld-web