Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Context Providers are not available (<DocsSidebarProvider />) #9094

Closed
5 of 7 tasks
dayhaysoos opened this issue Jun 22, 2023 · 8 comments
Closed
5 of 7 tasks
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)

Comments

@dayhaysoos
Copy link

Have you read the Contributing Guidelines on issues?

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 am converting a docs site to a monorepo by switching to pnpm. Everything seemed to run fine when I was using npm, however, after switching to pnpm, I'm getting ReactContext errors.

On our /learn path, I get this error:

Screenshot_2023-06-22_at_11 10 15_AM

Some how the <DocsSidebarProvider /> isn't being wrapped around the Docusaurus app.

Thank you in advanced!

Reproducible demo

https://github.com/TBD54566975/developer.tbd.website/tree/pnpm

Steps to reproduce

Step 1: pnpm i
Step 2: pnpm build

Or if you run pnpm start and navigate to the /learn URL, you'll see the ContextProvider error.

Expected behavior

I expect that there should be no errors because the appropriate ContextProviders are in place.

Actual behavior

Throwing error that says useDocsSidebar hook is being used outside of <DocsSidebarProvider />

Screenshot_2023-06-22_at_11 10 15_AM

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@dayhaysoos dayhaysoos added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 22, 2023
@slorber
Copy link
Collaborator

slorber commented Jun 22, 2023

You probably have some duplicate packages in your node modules.
Not sure it can be considered as a Docusaurus bug.

Did you also upgrade at the same time, or the only change was the package manager?

Can I see a failing PR or something that clearly shows a diff? (ok before, failing after)

@dayhaysoos
Copy link
Author

Hey @slorber!

I did upgrade only to see if that would fix my issue. I went from 2.4.0 to 2.4.1.

I just created this PR:

TBD54566975/developer.tbd.website#564

main has the same folder structure but we're running npm commands directly in site and all of those are working just fine.

The pnpm branch is where the context errors are happening.

@slorber
Copy link
Collaborator

slorber commented Jun 23, 2023

Your pnpm branch is working for me locally with start/build and pnpm 8.6.3:

CleanShot 2023-06-23 at 11 12 24@2x

Try docusaurus clear and test again?

Netlify CI does show an error though but it's not the same that the one you reported 2:03:02 AM: [ERROR] Error: Cannot mix different versions of joi schemas: https://app.netlify.com/sites/tbd-website-developer/deploys/6494e1064f21010008d33c92

Try also to clear the netlify cache and rebuild?

@slorber
Copy link
Collaborator

slorber commented Jun 23, 2023

Apparently, you got it working on Netlify a few hours ago, so I assume the problem is fixed 🤷‍♂️
https://app.netlify.com/sites/tbd-website-developer/deploys/6494e19ed6e84b1663a769f3

Not sure we can do anything on the Docusaurus codebase anyway so I'm going to close

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2023
@slorber slorber added closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed status: needs triage This issue has not been triaged by maintainers labels Jun 23, 2023
@dayhaysoos
Copy link
Author

Hey @slorber,

I was gonna do some experimenting this morning before updating this issue, but here is what ended up being the fix:

#7880 (comment)

Perhaps removing @docusaurus/types from being an optional dependency would be the answer for pnpm users? Not sure if that might cause issues elsewhere, though.

@slorber
Copy link
Collaborator

slorber commented Jun 23, 2023

Thanks

That looks related to a few issues we have (also this one: #9080)

Will need to investigate this a bit but that seems reasonable to include the types as direct deps (even for JS projects, considering we use JSDoc types in the site config)

@yoavniran
Copy link

came across this at: https://github.com/rpldy/react-uploady-docs
after upgrading from 3.0.0 to 3.1.1.
Strangely, it only happened when serving and navigating to a single page: /docs/guides/ (generated directory index) and no other.
Of course, build was breaking during server-side build.

fixed by removing node_modules and reinstalling (pnpm)

@slorber
Copy link
Collaborator

slorber commented Feb 21, 2024

When this happens this is usually because there are competing versions of the same package in your repo.

Double-checking your dependencies, and regenerating your lockfile is usually a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)
Projects
None yet
Development

No branches or pull requests

3 participants