question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 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

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:)

  1. Install @docusaurus/plugin-content-docs@2.0.0-beta.5
  2. 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:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Sep 4, 2021

It should be. We tend to add @types/* dependencies in devDeps but I guess it makes more sense to put them in dependencies for module-type-aliases and types whose sole purpose is to provide typings

1reaction
ocavuecommented, Sep 3, 2021

@slorber @Josh-Cena After installing @types/react-router-dom and @types/react-helmet as 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.

Read more comments on GitHub >

github_iconTop 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 >

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