-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Conflicting versions when using canary releases + third-party plugins #7728
Comments
@slorber I'd like to add that the error messages can be highly confusing in this situation. The F12 console error looks like this:
...and if you dig out the error string, it's complaining that At first I was bisecting the Git history, looking for some Docusaurus release where It was just a very unlucky direction to happen to choose for debugging: The reason why And so the fix is to override versions and eliminate the side-by-side versions from But wow, is there SOME WAY that Docusaurus's plugin framework could provide better safeguards or diagnostics for this trap? My scenario was pretty common -- just trying to upgrade Docusaurus, getting a weird crash, and believing what the error message was telling me. 🙂 |
Sorry about your experience This kind of error can happen in any client-side app using npm unfortunately, and it's a quite common issue in React and Node.js world.
I don't have a clear answer to that. Maybe we could scan the node modules for duplicated packages or something 🤷♂️ Curious to know what others are doing to prevent this kind of issue. I wish React would fail fast in such a case, but afaik since React 17 they support better micro-frontends and using multiple versions of React on the same page is perfectly allowed |
Im not sure if this is related but is there a fixed for what you suggested @octogonz Using React 17.0.1 and Docusaurus 2.3.1 |
@yannickrocks Yes, as I explained the problem is that two different instances of React got installed in the node_modules folder. Since we're using PNPM, we were able to use Lockfile Explorer to figure out the cause of this problem and fix it. Usually it just involves making the package.json versions consistent between projects, or sometimes adding an override such as |
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Let's imagine you are using a canary release of Docusaurus, and also a third-party plugin.
You likely have this in your package.json file:
Problem:
@easyops-cn/docusaurus-search-local
depends on many Docusaurus core packages with semver range^2.0.0-beta.20
, and^2.0.0
does not match0.0.0
This potentially leads to duplicate core package installs in your repo, and multiple versions of the same package being used at runtime.
This is particularly problematic for packages exporting React providers because contexts are now duplicated, leading to weird issues like this one #7686 (comment)
A workaround is to use things like npm/yarn resolutions so that the user forces the package manager to duplicate packages.
We'll probably move
@docusaurus/theme-common
to peerDependency in the future, as it's the package most likely to cause troubles (exporting many React contexts)Another possibility is to change another time the canary versioning scheme, maybe using
3.0.0-something
for the canaries after we release 2.0? This should be changed carefully, as this scheme has been the source of troubles in the past, see #5295)Reproducible demo
No response
Steps to reproduce
see #7686 (comment)
Expected behavior
Use canary + third-party plugin without duplicated packages and weird React context issues
Actual behavior
see #7686 (comment): unexpected React context issues
Your environment
Self-service
The text was updated successfully, but these errors were encountered: