Skip to content

Unable to build website for locale en; TypeError: pathname.match is not a function #7532

@chrisui

Description

@chrisui

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

A TypeError appears on build. start works fine.

A google search comes up with some information on the inputs of this api changing in a recent react-router release (~3 months ago) so perhaps something out of sync.

https://stackoverflow.com/questions/71100360/react-router-error-pathname-match-is-not-a-function

Reproducible demo

N/A

Steps to reproduce

docusaurus build

Config is fairly vanilla as follows. Note same behaviour without typedoc plugin.

// @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: 'Docs',
  tagline: '-',
  url: 'https://google.com',
  baseUrl: '/',
  onBrokenLinks: 'throw',
  onBrokenMarkdownLinks: 'warn',
  favicon: 'img/favicon.ico',
  noIndex: true,
  i18n: {
    defaultLocale: 'en',
    locales: ['en'],
  },
  presets: [
    [
      'classic',
      /**
       * @type {import('@docusaurus/preset-classic').Options}
       */
      ({
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
          routeBasePath: '/',
          editUrl: 'https://github.com/-/edit/main/x/x',
          path: '../../',
          include: ['**/*.md', '**/*.mdx'],
          exclude: [
            'node_modules/**/*.md*',
            '**/node_modules/**/*.md*',
            '**/build/**/*.md*',
            '**/dist/**/*.md*',
            '**/__tests__/**/*.md*',
            '**/pages/**/*.md*',
            '**/*.ts*',
            'README.md*',
          ],
          showLastUpdateAuthor: true,
          showLastUpdateTime: true,
          editCurrentVersion: true,
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
        blog: false,
        sitemap: false,
      }),
    ],
  ],

  themeConfig:
    /**
     * @type {import('@docusaurus/preset-classic').ThemeConfig}
     */
    ({
      navbar: {
        logo: {
          alt: '-',
          src: 'img/logo.svg',
        },
        items: [
          {
            type: 'docSidebar',
            sidebarId: 'docs',
            label: 'Documentation',
            position: 'left',
          },
          {
            type: 'docSidebar',
            sidebarId: 'api',
            label: 'API',
            position: 'left',
          },
          {
            href: 'https://github.com/o',
            label: 'GitHub',
            position: 'right',
          },
        ],
      },
      footer: {
        style: 'light',
        links: [
          {
            title: 'More',
            items: [
              {
                label: 'GitHub',
                href: 'https://github.com/',
              },
            ],
          },
        ],
        copyright: `Copyright © ${new Date().getFullYear()} -.`,
      },
      prism: {
        theme: lightCodeTheme,
        darkTheme: darkCodeTheme,
      },
    }),

  plugins: [
    ['@cmfcmf/docusaurus-search-local', { indexBlog: false }],
    [
      'docusaurus-plugin-typedoc',
      {
        entryPoints: ['../lib-service'],
        entryPointStrategy: 'packages',
        sidebar: {
          fullNames: true,
        },
        readme: 'none',
      },
    ],
  ],
}

module.exports = config

Expected behavior

Successful build

Actual behavior

[ERROR] Unable to build website for locale en.
[ERROR] TypeError: pathname.match is not a function
    at Object.matchPath (~/node_modules/react-router/umd/react-router.development.js:789:26)
    at ~/node_modules/react-router-config/cjs/react-router-config.js:16:42
    at Array.some (<anonymous>)
    at matchRoutes (~/node_modules/react-router-config/cjs/react-router-config.js:15:10)
    at ~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:36:63
    at Array.map (<anonymous>)
    at isBrokenLink (~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:36:14)
    at ~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:40:53
    at Array.filter (<anonymous>)
    at getPageBrokenLinks (~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:40:39)
    at ~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:54:99
    at ~/node_modules/lodash/lodash.js:13469:38
    at ~/node_modules/lodash/lodash.js:4967:15
    at baseForOwn (~/node_modules/lodash/lodash.js:3032:24)
    at Function.mapValues (~/node_modules/lodash/lodash.js:13468:7)
    at getAllBrokenLinks (~/node_modules/@docusaurus/core/lib/server/brokenLinks.js:54:45)

Your environment

  • Public source code: N/A
  • Public site URL: N/A
  • Docusaurus version used:2.0.0-beta.21
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node v16.15.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):Ubuntu 18 WSL

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalThis issue is caused by an external dependency and not Docusaurus.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions