err: TypeError: parseDocument is not a function

This issue has been tracked since 2022-08-13.

It's a stupid question, but I really cant find it out:

const { parseDocument, parseDOM } = require('htmlparser2')

parseDOM is OK, parseDocument is not found in the module import:

const parser = require('htmlparser2')
console.log(parser)
{
  Parser: [Function: Parser],
  Tokenizer: [Function: Tokenizer],
  ElementType: {...},
  DomHandler: [Function: DomHandler],
  FeedHandler: [Getter],
  Stream: [Getter],
  WritableStream: [Getter],
  ProxyHandler: [Getter],
  DomUtils: [Getter],
  CollectingHandler: [Getter],
  DefaultHandler: [Function: DomHandler],
  RssHandler: [Getter],
  parseDOM: [Function: parseDOM],
  parseFeed: [Function: parseFeed],
  createDomStream: [Function: createDomStream],
  EVENTS: {...}
}
  • "version": "8.0.1"
  • node -v: v14.20.0
fb55 wrote this answer on 2022-08-18

Thanks for the detailed issue! I can tell that your local version is not 8.0.1, as the FeedHandler was removed in that version. Clearing out dependencies and reinstalling them usually does the trick.

Mahoo12138 wrote this answer on 2022-08-18

Thanks for the detailed issue! I can tell that your local version is not 8.0.1, as the FeedHandler was removed in that version. Clearing out dependencies and reinstalling them usually does the trick.

Yeah! It is 8.1.0 this morning, but now it is 4.1.0 after checking it out carefully🤣.
I saw parseDocument it in the type file clearly, so weird.
But it doesn't matter anymore,thank you so much, you are an amazing dev!

More Details About Repo
Owner Name fb55
Repo Name htmlparser2
Full Name fb55/htmlparser2
Language TypeScript
Created Date 2011-08-27
Updated Date 2023-03-19
Star Count 3793
Watcher Count 50
Fork Count 370
Issue Count 4

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date