cmfcmf / docusaurus-search-local

Offline / Local Search for Docusaurus v2. Try it live at:
https://cmfcmf.github.io/OpenWeatherMap-PHP-API/
MIT License
444 stars 67 forks source link

version 1.2.0 fails building docusaurus in node version 22.11.0 #224

Open micheleatzori opened 2 hours ago

micheleatzori commented 2 hours ago

Please describe the bug you are seeing

I've installed plugin version 1.2.0 and building my docusaurus website it raises the following error:

[ERROR] Error: Unable to build website for locale en.
    at tryToBuildLocale (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:54:19)
    at async /Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:65:9
    at async mapAsyncSequential (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
    at async Command.build (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:63:5) {
  [cause]: TypeError: Cannot read properties of undefined (reading 'load')
      at html2text (/Users/micheleatzori/smile.cx-docs/node_modules/@cmfcmf/docusaurus-search-local/lib/server/parse.js:79:33)
      at /Users/micheleatzori/smile.cx-docs/node_modules/@cmfcmf/docusaurus-search-local/lib/server/index.js:287:91
      at async Promise.all (index 0)
      at async Object.postBuild (/Users/micheleatzori/smile.cx-docs/node_modules/@cmfcmf/docusaurus-search-local/lib/server/index.js:284:26)
      at async /Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:187:9
      at async Promise.all (index 7)
      at async executePluginsPostBuild (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:183:5)
      at async buildLocale (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:143:5)
      at async tryToBuildLocale (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:47:13)
      at async /Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:65:9
      at async mapAsyncSequential (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
      at async Command.build (/Users/micheleatzori/smile.cx-docs/node_modules/@docusaurus/core/lib/commands/build.js:63:5)
}

[INFO] Docusaurus version: 3.5.2 Node version: v22.11.0

Any idea to solve this? Thanks

How can we best reproduce the bug?

No response

Which version of Docusaurus and @cmfcmf/docusaurus-search-local are you using?

├─┬ @cmfcmf/docusaurus-search-local@1.2.0 overridden
│ └── @docusaurus/core@3.5.2 deduped
├── @docusaurus/core@3.5.2
├─┬ @docusaurus/plugin-content-docs@3.5.2
│ └── @docusaurus/core@3.5.2 deduped
├─┬ @docusaurus/preset-classic@3.5.2
│ ├── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-content-blog@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-content-pages@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-debug@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-google-analytics@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-google-gtag@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-google-tag-manager@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ ├─┬ @docusaurus/plugin-sitemap@3.5.2
│ │ └── @docusaurus/core@3.5.2 deduped
│ └─┬ @docusaurus/theme-search-algolia@3.5.2
│   └── @docusaurus/core@3.5.2 deduped
├─┬ @docusaurus/theme-classic@3.5.2
│ └── @docusaurus/core@3.5.2 deduped
└─┬ docusaurus-plugin-sass@0.2.5
  └── @docusaurus/core@3.5.2 deduped

Which Node.js version are you using?

v 22.11.0

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

No response

Additional context

No response

lattaai1 commented 2 hours ago

Hello, I've fixed this issue!

This is what I've done: I have identified the issue in the html2text function within the parse.ts file. The error occurs when trying to access the load property of an undefined object. To fix this, I'll add a null check before accessing the load property of the cheerio object.

I also created pull request: https://github.com/cmfcmf/docusaurus-search-local/pull/225

[!CAUTION]
Disclaimer: This fix was created by Latta AI and you should never merge before you check the correctness of generated code!


This bug was fixed for free by Latta AI - https://latta.ai/ourmission