‘normalizeWhitespace’ does not exist in type ‘CheerioOptions’ Node

After updating Node module cheerio from 0.22.0 to 1.0.0-rc.12 I have the following error

Object literal may only specify known properties, and 'normalizeWhitespace' does not exist in type 'CheerioOptions'.

normalizeWhitespace: true,

Code:

const $ = load(html, {
  decodeEntities: true,
  normalizeWhitespace: true,
});

If I remove the option the behaviour changes but I don’t find which option should I use instead.

I have node v18

  • 1

    The option to normalizewhitespace was removed from newer versions of cheerio due to its inadequate coverage of edge cases in HTML. To address this issue, it is recommended to utilize a library like html-minifier-terser, which effectively implements whitespace compression. By integrating this library into your workflow, you can achieve the desired normalization of whitespace before using cheerio. This ensures a smoother, more accurate processing of your HTML code.

    – 

  • What are you trying to do that requires normalizing whitespace?

    – 

Leave a Comment