Skip to content

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

Closed as not planned

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.

Activity

  1. added
    bug
    status: needs triage
    on May 30, 2022
  2. Josh-Cena commented on May 30, 2022

    @Josh-Cena
    Collaborator

    So can I get a repro, please?

    @chrisui I'm going to close this next week if there isn't a way to reproduce this.

  3. added
    status: needs more information
    and removed
    status: needs triage
    on May 30, 2022
  4. Josh-Cena commented on May 30, 2022

    @Josh-Cena
    Collaborator

    I think I've seen this error some time ago, while playing with very bad things...

    Do you know if you have another version of react-router installed? What happens when you run yarn why react-router (assuming you are using yarn)?

  5. chrisui commented on May 31, 2022

    @chrisui
    Author

    So can I get a repro, please?

    @chrisui I'm going to close this next week if there isn't a way to reproduce this.

    Tried but couldn't. As the error isolated this very exclusively to a specific usage of react-router I figured it worth opening an issue anyway as there may be an obvious misusage.

    I don't yet have enough knowledge of Docusaurus architecture to determine how to bisect our large codebase of documentation to filter out to the specific repro which may have an affect on this breaking code path. Can work towards a repro with some context-aware advice as you've helpfully suggested with react-router installation.

    I think I've seen this error some time ago, while playing with very bad things...

    Do you know if you have another version of react-router installed? What happens when you run yarn why react-router (assuming you are using yarn)?

    Using npm workspaces, all dependencies hoisted. Don't have react-router installed directly. Appears @storybook is the other package that references it at a later version. Some module resolution issue perhaps then. What scope would docusaurus be resolving the module from?

    See npm ls --depth 5 and npm explain react-router outputs below.

    npm-ls.txt

    npm-explain-react-router.txt

  6. chrisui commented on May 31, 2022

    @chrisui
    Author

    Unfortunately unable to get the codesandbox working. Repro I'm trying to test is adding the @storybook/addon-links@6.4.9 as a dependency (which depends somewhere on react-router@6.2.1) and then moving the docusaurus.config.js to a nested directory with classic preset docs configured to: path: '../../', include: ['**/*.md', '**/*.mdx']

    Screenshot 2022-05-31 at 13 51 04

  7. Josh-Cena commented on May 31, 2022

    @Josh-Cena
    Collaborator

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

  8. chrisui commented on May 31, 2022

    @chrisui
    Author

    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.

  9. added
    external
    and removed
    bug
    status: needs more information
    on Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    external

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions