Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search index not working after node upgrade #454

Closed
KevinFarmerRXM opened this issue Aug 29, 2024 · 4 comments
Closed

Search index not working after node upgrade #454

KevinFarmerRXM opened this issue Aug 29, 2024 · 4 comments

Comments

@KevinFarmerRXM
Copy link

KevinFarmerRXM commented Aug 29, 2024

Hi,

My docusaurus site builds with a search index locally using the config below. After a recent upgrade to node.js on our production server, the build fails with this error:

[ERROR] Unable to build website for locale en.
[ERROR] TypeError: Cannot read properties of undefined (reading 'load')
    at parse (c:\jenkins\workspace\support_docs_master\node_modules\@easyops-cn\docusaurus-search-local\dist\server\server\utils\parse.js:9:33)
    at c:\jenkins\workspace\support_docs_master\node_modules\@easyops-cn\docusaurus-search-local\dist\server\server\utils\scanDocuments.js:24:75
    at Generator.next (<anonymous>)
    at fulfilled (c:\jenkins\workspace\support_docs_master\node_modules\tslib\tslib.js:166:62)

Prior to the upgrade, the site was not building and throwing the error:

The engine "node" is incompatible with this module. Expected version ">=18.17". Got "18.15.0"

However, I didn't investigate this and simply upgraded node.js.

Locally, I am running node v20.16.0. Our production server was upgraded to v20.14.0. The docusaurus version is 2.3.1. The package file contains:

"@easyops-cn/docusaurus-search-local": "^0.35.0",

Issue 320 seemed similar so I tried the production build with and without the values for routeBasePath and docsRouteBasePath that are commented out below.

At best, the site builds without indexing. At worst, it doesn't build. The production build does have a file search.html, but it is quite small.

presets:
    [
        [
            'classic',
            /** @type {import('@docusaurus/preset-classic').Options} */
            ({
                docs:
                {
                    //routeBasePath: '/',
                    sidebarPath: require.resolve('./sidebars.js'),
                    sidebarCollapsible: true,
                    sidebarCollapsed: true,
                },                
                theme:
                {
                    customCss: require.resolve('./src/css/custom.css'),
                },
            }),
        ],
    ],
    
    // themes:
    // [
        
    // ],

    plugins:
    [
        require.resolve('docusaurus-plugin-image-zoom'),
        [
            require.resolve('@easyops-cn/docusaurus-search-local'),
            {
                //docsRouteBasePath: "/",
                hashed: true,
                language: ["en"],
                highlightSearchTermsOnTargetPage: true,
                explicitSearchResultPath: true,
                searchResultLimits: 8,
                ignoreFiles: [/.solutions./],
            },
        ]
    ],

Let me know if I should provide any more details.
Thanks

@weareoutman
Copy link
Member

Seems to be the same issue of #444 related to an update of a dependency named cheerio. Try v0.44.5 or above.

@weareoutman
Copy link
Member

I noticed you're using Docusaurus v2, you may try downgrade instead of upgrade, see this comment #447 (comment)

@KevinFarmerRXM
Copy link
Author

Thanks!

Sorry for the delayed reply. It seems a few things needed to be fixed. Along the way I upgraded docusaurus and some modules.

The build now throws only this error:

Module not found: Error: Can't resolve '@generated/site-storage' in 'c:\jenkins\workspace\<redacted>\node_modules\@easyops-cn\docusaurus-search-local\node_modules\@docusaurus\theme-common\lib\utils'

package.json

{
  "name": "docs-rxmsupport",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@docusaurus/core": "3.0.0",
    "@docusaurus/preset-classic": "3.0.0",
    "@easyops-cn/docusaurus-search-local": "^0.44.5",
    "@mdx-js/react": "^3.0.0",
    "clsx": "^1.2.1",
    "docusaurus-plugin-image-zoom": "^0.1.1",
    "prism-react-renderer": "^2.1.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "3.0.0",
    "@docusaurus/types": "3.0.0"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "engines": {
    "node": ">=18.0"
  }
}

@KevinFarmerRXM
Copy link
Author

This is exactly issue #447 (comment). I'll post to that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants