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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
chrisuicommented, May 31, 2022

Have resolved this now, thank you for the pointer. The issue was an invalid package-lock.json (oh, npm) which incorrectly hoisted v6 of react-router rather than v5 and put v6 local to storybook.

I had essentially copied my entire repo to a new environment and been unable to reproduce when I decided to compare package-lock.json between my actual repo and the repro repo. Problem became obvious then and I nuked the incorrect package-lock.json and re-generated.

1reaction
Josh-Cenacommented, May 31, 2022

Maybe try a fresh installation locally? I actually prefer a GH repository to a CodeSandbox, if that works for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router error pathname.match is not a function
You are using react-router v6 that the order of matchPath arguments is inverted in new version: declare function matchPath< ParamKey extends ...
Read more >
typeerror: cannot read property 'pathname' of undefined - You.com ...
I am creating sign-up and sign-in on a website but I am getting this error TypeError: Cannot read property 'pathname' of undefined I...
Read more >
Data Fetching: getStaticProps - Next.js
Exporting a function called getStaticProps will pre-render a page at build time using the props returned from the function:
Read more >
The Ultimate Vue Localization Guide | Phrase
Dive into Vue localization and learn how to plug the Vue I18n library into your app, so you can make it accessible to...
Read more >
Sitemap Implementation - Docs
Listeners; Resolvers; Utility Functions. Single Page App Handling. Sitemap Localization Implementation. Example: Setting Locale in the Global Configuration ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found