Yarn: resolutions doesn't work with deps that have '/' in their name

Created on 7 Nov 2017  路  7Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Resolutions for packages that use namespacing aren't respected.
example:

  "resolutions": {
    "@types/storybook__react/@types/react": "16.0.20"
  },

resulting yarn.lock still declares an older version of @types/react for @types/storybook__react

Please mention your node.js, yarn and operating system version.
node: v6.9.1
yarn: 1.3.2
Ubuntu 16.04.3 LTS

triaged

Most helpful comment

I think I was able to get this to work by specifying the resolution like this:

  "resolutions": {
    "**/@types/PackageA/**/@types/PackageB": "x.y.z"
  },

All 7 comments

Any progress on this one? I'm facing the same issue.

Resolutions with an @ do not seem to work.
The following doesn't work for me:

    "resolutions": {
        "@storybook/**/ts-loader": "3.5.0"
    },

EDIT: I just realized that @storybook does not have the ts-loader dependency as such. I'm just using ts-config in my custom webpack.config for storybook. So I believe this will not work with resolutions, am I right?


Versions:
node: 8.10.0
yarn: 1.9.4
Ubuntu 18.04.1 LTS

@arcanis Hi, is there any progress on this? I'm facing a similar issue with a nested dependency.

@burabure (or anyone else) did you happen to find a work around for this?

I'm debating republishing the package ~with~ without a slash to get around this.

Edit: I was able to find some work being done around selective resolutions: https://github.com/yarnpkg/yarn/pull/4243

It's possible I'm misunderstanding how to utilize these.

My current setup is I have a root workspace with these children inside:
Project A package.json (which is the source of the issue):

   dependencies: {
      backbone.marionette: '2.4.1'
   }

Project B package.json (which is the application having issues):

   dependencies: {
         backbone.marionette: '1.8.8',
         @organization/UILibrary: '0.0.22'
   }

The @organization/UILibrary (which is outside the workspace) package.json looks like so:

      peerDependencies: {
           backbone.marionette: ">= 1 < 3"
      }

Unfortunately, even though Project B has no dependency on Project A, when @organization/UILibrary is pulled into Project B it gets backbone.marionette version 2.4.1 for it's requires (whereas the requires local to Project B get 1.8.8).

My attempt to use resolutions is updating Project B package.json to this:

   dependencies: {
         backbone.marionette: '1.8.8',
         @organization/UILibrary: '0.0.22'
},
{
"resolutions": {
    "@organization/**/backbone.marionette": "1.8.8",
    "@organization/backbone.marionette": "1.8.8",
    "@organization/UILibrary/backbone.marionette: "1.8.8",
    "@organization/UILibrary/**/backbone.marionette: '1.8.8"
  }
}

Any ideas? I can add more details if people need them, and if desired I can open a different issue (sorry if I'm hijacking this one, but it seemed relevant).

It's 2020, is there any update on this? Seems like an edge-case that should've been covered.

I'm running into an issue with a type definition package, and trying to do something like this:

  "resolutions": {
    "@types/PackageA/**/@types/PackageB": "x.y.z"
  },

I was hoping to use yarn resolutions and not have to use declaration merging.

I think I was able to get this to work by specifying the resolution like this:

  "resolutions": {
    "**/@types/PackageA/**/@types/PackageB": "x.y.z"
  },

That's a huge issue, @types/react can't be installed properly

Was this page helpful?
0 / 5 - 0 ratings