Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
externalThis issue is caused by an external dependency and not Docusaurus.
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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 = configExpected 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
Labels
externalThis issue is caused by an external dependency and not Docusaurus.
Activity
Josh-Cena commentedon May 30, 2022
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.
Josh-Cena commentedon May 30, 2022
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)?chrisui commentedon May 31, 2022
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.
Using npm workspaces, all dependencies hoisted. Don't have react-router installed directly. Appears
@storybookis 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 5andnpm explain react-routeroutputs below.npm-ls.txt
npm-explain-react-router.txt
chrisui commentedon May 31, 2022
Unfortunately unable to get the codesandbox working. Repro I'm trying to test is adding the
@storybook/addon-links@6.4.9as a dependency (which depends somewhere on react-router@6.2.1) and then moving thedocusaurus.config.jsto a nested directory with classic preset docs configured to:path: '../../', include: ['**/*.md', '**/*.mdx']Josh-Cena commentedon May 31, 2022
Maybe try a fresh installation locally? I actually prefer a GH repository to a CodeSandbox, if that works for you.
chrisui commentedon 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.