docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Types aren't recognized if the project is setup with pnpm

Open onattech opened this issue 2 years ago • 2 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] 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.
  • [X] I have tried creating a repro with https://new.docusaurus.io.
  • [X] I have read the console error message carefully (if applicable).

Description

If a project is initialized with pnpm, types aren't being recognized. This is not an issue with npm. Manually importing missing types fixes the errors. So I wanted to report this as it may be a bug. Tested it on latest 2.4.1 and canary Alpha3.0.0.

Reproducible demo

No response

Steps to reproduce

You may reproduce this issue by starting a new project with the command pnpm create docusaurus. Yes, I did select the typescript option during setup.

Expected behavior

It should recognize types similar to when installed with npm.

Actual behavior

Getting missing type errors. image image Also getting errors for and not limited to node types, react types etc.

Solution Manually installing types like so image

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • [ ] I'd be willing to fix this bug myself.

onattech avatar Jun 18 '23 13:06 onattech

It should be mentioned that, as is shown in the issue mentioned above, in version 3 of Docusaurus there are 2 type errors: one for @docusaurus/theme-classic and another for node. Installing @docusaurus/theme-classic fixes the former and installing @types/node fixes the latter. Both can be installed as development dependencies as a temporary fix to make the command pass.

albertothedev avatar Nov 17 '23 14:11 albertothedev

It should be mentioned that, as is shown in the issue mentioned above, in version 3 of Docusaurus there are 2 type errors: one for @docusaurus/theme-classic and another for node. Installing @docusaurus/theme-classic fixes the former and installing @types/node fixes the latter. Both can be installed as development dependencies as a temporary fix to make the command pass.

Yeah, indeed it is a solution.

SalahAdDin avatar Feb 02 '24 16:02 SalahAdDin