docusaurus-search-local icon indicating copy to clipboard operation
docusaurus-search-local copied to clipboard

[ERROR] TypeError: Cannot read properties of undefined (reading 'load')

Open gentledepp opened this issue 10 months ago • 10 comments

Please describe the bug you are seeing

I am building my docusaurus project, and I get this error

[Local Search] [INFO]: Gathering documents
[Local Search] [INFO]: Parsing documents
[ERROR] Unable to build website for locale en.
[ERROR] TypeError: Cannot read properties of undefined (reading 'load')
    at html2text (C:\Code\iCL.Documentation.V2\docs\node_modules\@cmfcmf\docusaurus-search-local\lib\server\parse.js:79:33)      
    at C:\Code\iCL.Documentation.V2\docs\node_modules\@cmfcmf\docusaurus-search-local\lib\server\index.js:286:99
    at async Promise.all (index 0)
    at async Object.postBuild (C:\Code\iCL.Documentation.V2\docs\node_modules\@cmfcmf\docusaurus-search-local\lib\server\index.js:283:32)
    at async C:\Code\iCL.Documentation.V2\docs\node_modules\@docusaurus\core\lib\commands\build.js:180:9
    at async Promise.all (index 6)
    at async buildLocale (C:\Code\iCL.Documentation.V2\docs\node_modules\@docusaurus\core\lib\commands\build.js:176:5)
    at async tryToBuildLocale (C:\Code\iCL.Documentation.V2\docs\node_modules\@docusaurus\core\lib\commands\build.js:41:20)      
    at async mapAsyncSequential (C:\Code\iCL.Documentation.V2\docs\node_modules\@docusaurus\utils\lib\jsUtils.js:34:24)
    at async Command.build (C:\Code\iCL.Documentation.V2\docs\node_modules\@docusaurus\core\lib\commands\build.js:76:21)
[INFO] Docusaurus version: 2.4.3
Node version: v20.13.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

How can we best reproduce the bug?

No response

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

I am using docusaurus with the following dependencies

"dependencies": {
    "@cmfcmf/docusaurus-search-local": "1.2.0",
    "@docusaurus/core": "2.4.3",
    "@docusaurus/plugin-ideal-image": "2.4.3",
    "@docusaurus/preset-classic": "2.4.3",
    "@mdx-js/react": "1.6.22",
    "clsx": "1.2.1",
    "prism-react-renderer": "1.3.5",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-gif-player": "0.4.2"
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "2.4.3",
    "@tsconfig/docusaurus": "1.0.7",
    "typescript": "^5.0.0"  
  },

This is my tsconfig.json

{
  "extends": "@tsconfig/docusaurus/tsconfig.json",
  "compilerOptions": {
    "baseUrl": ".",
    "moduleResolution": "Node16",
    "module": "Node16"
  }
}

Which Node.js version are you using?

No response

Which theme are you using?

Yes, I am using @docusaurus/theme-classic

How does your plugin config look like?

// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');

/** @type {import('@docusaurus/types').Config} */
const config = {
  title: 'iCL Documentation',
  tagline: 'Learn how to master the iCL product family',
  url: 'https://docs.opti-q.com',
  baseUrl: '/',
  onBrokenLinks: 'throw',
  onBrokenMarkdownLinks: 'warn',
  favicon: 'img/optiq.ico',
  organizationName: 'Opti-Q', // Usually your GitHub org/user name.
  projectName: 'iCL', // Usually your repo name.
  
  plugins: [
    // automatically creates thumbnails in multiple sizes
    [
      '@docusaurus/plugin-ideal-image',
      {
        quality: 70,
        max: 1030, // max resized image's size.
        min: 320, // min resized image's size. if original is lower, use that size.
        steps: 3, // the max number of images generated between min and max (inclusive)
        disableInDev: true,
      },
    ],
    // supports search (does NOT work in development mode)
    // 20240912 - had to remove this plugin as it breaks the build! (wait for npm package update from this repo: https://github.com/cmfcmf/docusaurus-search-local)
    // https://github.com/cmfcmf/docusaurus-search-local
    [
      require.resolve("@cmfcmf/docusaurus-search-local"),
      {
        language:['en', 'de']
      },
    ],
  ],
  presets: [

Additional context

It seems to have to do with this line: image but I have no clue what is going on there.

When looking at the cheerio index.js that is shown here in the popup: image

There is no "default" field or anything like that. (Sorry, I am not a node specialist :-|)

Can you please give ma any hint on what I could try to do?

gentledepp avatar Dec 31 '24 10:12 gentledepp