Module '"@docusaurus/router"' has no exported member 'matchPath'
See original GitHub issue🐛 Bug Report
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
I’m using docusaurus in a TypeScript project. When we run tsc -b to build the project, we get this error:
> tsc -b
node_modules/.pnpm/@docusaurus+plugin-content-docs@2.0.0-beta.5_react-dom@17.0.2+react@17.0.2/node_modules/@docusaurus/plugin-content-docs/src/client/docsClientUtils.ts:8:9 - error TS2305: Module '"@docusaurus/router"' has no exported member 'matchPath'.
8 import {matchPath} from '@docusaurus/router';
~~~~~~~~~
@docusaurus/plugin-content-docs imports matchPath from @docusaurus/router. But I couldn’t find @docusaurus/router in my node_modules nor https://www.npmjs.com/.
Have you read the Contributing Guidelines on issues?
yes
Steps to reproduce
Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.
(Write your steps here:)
- Install
@docusaurus/plugin-content-docs@2.0.0-beta.5 - Use TypeScript to compile the project
Expected behavior
No error.
If @docusaurus/router doesn’t mean to be an NPM package, then maybe docusaurus should export .d.ts files instead of raw .ts files as types.
Actual behavior
Got error.
Your environment
- Public source code: N/A
- Public site URL: N/A
- Docusaurus version used:
@docusaurus/plugin-content-docs@2.0.0-beta.5 - Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node.js v16.7.0, TypeScript 4.4.2, Pnpm 6.14.5
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 11.5
Reproducible demo
N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
TS2305: Module '"react-router"' has no exported member ...
Actual Behavior ./src/router.tsx. Attempted import error: 'Switch' is not exported from 'react-router'. Compiling.
Read more >2 - Stack Overflow
Module "Users/../node_modules/react-router" has no exported member 'match' · Ask Question. Asked 1 year, 8 months ago. Modified 10 months ago.
Read more >'"react-router-dom"' has no exported member named 'redirect ...
To solve the error "export 'Redirect' (imported as 'Redirect') was not found in 'react-router-dom'", use the `Navigate` component instead of `Redirect`, ...
Read more >docusaurus.config.js
It usually exports a site configuration object: ... module.exports = { ... For URLs that have no path, the baseUrl should be set...
Read more >Module '"react-router"' has no exported member 'match'. Code ...
module '"react-native"' has no exported member 'text'.ts(2305). whatever by Disgusted Dove on Aug 28 2021 Comment. 1. npm install --save @types/react-native.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It should be. We tend to add
@types/*dependencies in devDeps but I guess it makes more sense to put them in dependencies formodule-type-aliasesandtypeswhose sole purpose is to provide typings@slorber @Josh-Cena After installing
@types/react-router-domand@types/react-helmetas the document said, we don’t get this error anymore. Thank you for your help.I’m curious why don’t put these two packages as dependencies of Docusaurus so that we users don’t need to install them. I guess there is a reason and I just didn’t think of it.