Error: Assertion failed: Expected the resolution for webpack@npm:^5.54.0 [ef0ec] to have been registered
Discussed in https://github.com/yarnpkg/berry/discussions/4704
Originally posted by fabis94 August 4, 2022 Any idea what circumstances cause this kind of error to happen? I have a Vue project w/ Vue CLI and some plugins that I'm trying to upgrade from v4 to v5, but I'm getting this error and it's not exactly obvious what to do here. Couldn't find anything at all about this in Google either. So how should I debug this issue further?
Reproduction link: https://github.com/specklesystems/speckle-server/pull/888
Just check out that branch and do yarn
It started happening as I moved the webpack, @vue/cli-* dependencies up to latest versions in the frontend package.json
i'm having this issue with hardhat
I'm experiencing the same error with styled-component. The description for my setup is in #4704 comment.
The strange thing is that everything is installed in my setup but I cannot add react-dom packages after successfully adding styled-components.
Update -> Solution
As I explained in my previous writings, the main package that created the error was @mui/styled-engine-sc.
I removed the dependency on @mui/styled-engine-sc from my package.json and also used * as the version specifier for @mui/styled-engine. So my project's package.json would be like this:
{
"@mui/styled-engine": "*",
}
instead of
{
"@mui/styled-engine": "npm:@mui/[email protected]",
"@mui/styled-engine-sc": "latest",
}
and my resolutions stayed the same
{
"resolutions": {
"@mui/styled-engine-sc": "5.9.3",
"@mui/styled-engine": "npm:@mui/[email protected]",
"react": "17.0.2",
"react-dom": "17.0.2",
"styled-components": "5.3.3",
}
}
Update -> Source of Issue (for me at least)
By adding logs to the yarn source code where the error happens (https://github.com/yarnpkg/berry/blob/3741be55c97cc9b581ab049f4bcdadbd3eb20a07/packages/yarnpkg-core/sources/Project.ts#L2234) I could find the parent package that causes this issue. (I changed the yarn binary in .yarn/releases)
No surprise it was the @mui/styled-engine-sc. The MUI docs suggest that we add the following line to the yarn resolutions if we use styled-components instead of emotion: "@mui/styled-engine": "npm:@mui/[email protected]"
Looks like adding an npm protocol dependency like the above to the yarn resolutions creates a lot of issues. I think the issue is that the yarn has not resolved 'styled-componentswhen it tries to resolve@mui/styled-engine-sc` dependencies.
Previous Attempts
Here is what have I done so far that did not work for me:
- I tried to remove
yarn.lock, pnp files, and cache and install again which did not work. - I updated the yarn to 4.0.0-rc.14 using
yarn set version from sourceswith no luck again. - I remove everything related to yarn and ran yarn install again which did not work
- I tried to add other packages and everything works fine
I can install everything that exists in my package.json's but when I try to add [email protected] package using yarn add It says: Assertion failed: Expected the resolution for styled-components@npm:5.3.3 [10f61] to have been registered
Both styled-components and react-dom versions are fixed in my monorepo root (using yarn resolutions).
my resolutions field is something like this:
"react-dom": "17.0.2",
"styled-components": "5.3.3"
I also found out that styled-components package conflicts with react-dom@17 if I remove react-dom from resolutions and add react-dom@18 it successfully installs but adding react-dom@17 (without the resolutions field) fails.
Also removing styled-components seems to resolve the issue. Looks like styled-components and react-dom cannot coexist.
Would like to hear at least something from yarn maintainers, this bug is a showstopper
I am also having the same issue,
Is there a possible solution or explanation what does this error suggest. I can't figure out from the message.
Error: Assertion failed: Expected the resolution for react-router-dom@npm:^5.1.0 [0ed99] to have been registered
[11:18:40]➜ website: yarn add @testing-library/react17@npm:@testing-library/[email protected]
➤ YN0000: ┌ Resolution step
➤ YN0001: │ Error: Assertion failed: Expected the resolution for react-dom@npm:17.0.2 [b0b86] to have been registered
at website/.yarn/releases/yarn-3.6.3.cjs:446:3657
at Array.map (<anonymous>)
I also seem to have styled components in a different yarn workspace, but yes why is this incompatibility only showing up now when I try to add testing-library...
This ended up being irrelevant for me (even if I uninstalled styled-components same issue).
Also, in case this helps: if I install this package at the root of the repo (in the root's package.json) it works fine... only within this workspace does it give me the issue.
Edit: This was solved. The error message is misleading/wrong (maybe if you're having this the same might be for you.
In my case I used an alias to have 2 different packages that are actually the same one. Instead of telling me this is a clashing package. It told me this misleading error about react-dom.