facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.59k stars 8.5k forks source link

Cannot find module '@docusaurus/router' when importing useHistory #6938

Closed lanegoolsby closed 2 years ago

lanegoolsby commented 2 years ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

VSCode is complaining about missing types when referencing useHistory. The code works as expected, its just a nuisance seeing the error. I was unable to repo this in the Playground.

image

Reproducible demo

No response

Steps to reproduce

Add import { useHistory } from '@docusaurus/router'; to a TSX file

Expected behavior

No errors are shown

Actual behavior

Error is shown

Your environment

Here's my package.json

{
  "name": "tech-guidebook",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "docusaurus": "docusaurus",
    "start": "docusaurus start --no-open",
    "build": "docusaurus build",
    "swizzle": "docusaurus swizzle",
    "deploy": "docusaurus deploy",
    "clear": "docusaurus clear",
    "serve": "docusaurus serve",
    "write-translations": "docusaurus write-translations",
    "write-heading-ids": "docusaurus write-heading-ids"
  },
  "dependencies": {
    "@babel/runtime": "^7.17.2",
    "@docusaurus/core": "2.0.0-beta.17",
    "@docusaurus/preset-classic": "2.0.0-beta.17",
    "@emotion/react": "^11.8.2",
    "@emotion/styled": "^11.8.1",
    "@mdx-js/react": "^1.6.22",
    "@mui/material": "^5.5.1",
    "@reduxjs/toolkit": "^1.8.0",
    "algoliasearch": "^4.13.0",
    "clsx": "^1.1.1",
    "docusaurus-theme-search-typesense": "^0.4.0-2",
    "lodash": "^4.17.21",
    "prism-react-renderer": "^1.2.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-instantsearch-dom": "^6.22.0",
    "react-redux": "^7.2.6",
    "typesense": "^1.2.2",
    "typesense-instantsearch-adapter": "^2.4.0"
  },
  "devDependencies": {
    "@docusaurus/module-type-aliases": "^2.0.0-beta.17",
    "@docusaurus/types": "^2.0.0-beta.17",
    "@tsconfig/docusaurus": "^1.0.4",
    "@types/lodash": "^4.14.180",
    "@types/react": "^17.0.40",
    "@types/react-dom": "^17.0.13",
    "@types/react-instantsearch-dom": "^6.12.2",
    "@types/react-redux": "^7.1.23",
    "typescript": "^4.6.2"
  },
  "browserslist": {
    "production": [
      ">0.5%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Self-service

lanegoolsby commented 2 years ago

This is related to #3424

lanegoolsby commented 2 years ago

Found the problem. The tsconfig.json was missing this line

  "extends": "@tsconfig/docusaurus/tsconfig.json"