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.

issue and workaround for react-dom as a peer dependency (yarn 2 with workspaces)

See original GitHub issue

When using this package with yarn v2 (yarn berry), it throws while building:

Module not found: Error: use-context-selector tried to access react-dom (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

this error comes after resolving #134 by adding scheduler as a dependency 😉 (resolving this error is a bit easier than #134 - so I created another issue, hope this is fine for you)

You depend on use-context-selector, and they declared react-dom as a peerDependency. So you should also add react-dom to your peerDependencies to make sure, it is available.

workaround at the moment

Currently workaround is adding this to .yarnrc.yml

packageExtensions:
  jotai@*:
    peerDependencies:
      "react-dom": "*"

info about packageExtensions:

Some packages may have been specified incorrectly with regard to their dependencies - for example with one dependency being missing, causing Yarn to refuse it the access. The packageExtensions fields offer a way to extend the existing package definitions with additional information.

https://yarnpkg.com/configuration/yarnrc#packageExtensions

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Oct 17, 2020

So, for now our recommendation is the workaround described in https://github.com/pmndrs/jotai/issues/135#issue-723129121

packageExtensions:
  jotai@*:
    peerDependencies:
      "react-dom": "*"

or the one described in https://github.com/pmndrs/jotai/pull/139#issuecomment-710701325

  "dependencies": {
    "react": "^16.14.0",
    "react-dom": "^16.14.0"
  },
0reactions
dai-shicommented, Oct 17, 2020

TL;DR: If you write a package that depends on Foo, and if Foo has a peer dependency, then you must provide it in either of the dependencies or peerDependencies fields. You won’t “implicitly inherit” the peer dependencies declared in Foo.

Alright, I wasn’t aware this. Thanks for noting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manifest fields | Yarn - Package Manager
List of all the supported fields for a Yarn project manifest (package.json files)
Read more >
How to figure out why package is not hoisted in yarn3 ...
I'm using yarn 3 monorepo and for some reason, react-dom package is not hoisted properly: The same version of react-dom is duplicated across ......
Read more >
styled-components@5.3.5" has unmet peer dependency " ...
Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js. [2/4] Fetching packages.
Read more >
libfuse.so: error adding symbols: File in wrong format
Upgrade to fsevents 2. warning Lockfile has incorrect entry for ... has incorrect peer dependency "react-dom@^15.5.0". warning ...
Read more >
CRA and Yarn Workspace
If the current package has React components, you should declare react in peerDependencies . You can add big libraries which the sub-package is ......
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