yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

Unmet peer deps with workspaces #5810

Closed sky87 closed 3 years ago

sky87 commented 6 years ago

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

Bug

What is the current behavior? In workspaces, peerDependencies that are also present as devDependencies are reported as unmet.

If the current behavior is a bug, please provide the steps to reproduce. Clone https://github.com/sky87/unmet-peer-deps-issue, run

$ yarn
yarn install v1.6.0
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "workspace-aggregator-b6d53714-1712-40de-af51-af5d0487ed3e > a@1.0.0" has unmet peer dependency "react@^16.0.0".
warning "workspace-aggregator-b6d53714-1712-40de-af51-af5d0487ed3e > a@1.0.0" has unmet peer dependency "react-dom@^16.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 4.49s.

What is the expected behavior? Yarn should not issue a warning.

Notice that without workspaces everything works as expected.

$ rm -rf node_modules &&  mv package.json _package.json &&  cd packages/a && yarn
yarn install v1.6.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 2.04s.

Please mention your node.js, yarn and operating system version.

$ yarn -v
1.6.0
$ node -v
v9.3.0
$ ver
Microsoft Windows [Version 10.0.16299.431]
ghost commented 6 years ago

I don't think I'm using the workspace feature, but am getting the following error despite the fact that babel-runtime@6.26.0 is installed. I think it's because I'm using devDependencies as well.

warning "react-intl-cra > babel-preset-react-app@3.1.1" has unmet peer dependency "babel-runtime@^6.23.0".

My packages:

{
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "classnames": "^2.2.5",
    "eventemitter3": "^3.1.0",
    "history": "^4.7.2",
    "invariant": "^2.2.4",
    "lodash.debounce": "^4.0.8",
    "path-to-regexp": "2.2.1",
    "prop-types": "15.6.1",
    "query-string": "5.1.1",
    "react": "16.4.0",
    "react-bootstrap": "0.32.1",
    "react-delay-input": "^4.0.4",
    "react-dom": "16.4.0",
    "react-input-mask": "2.0.1",
    "react-intl": "^2.4.0",
    "react-loadable": "5.4.0",
    "react-overlays": "^0.8.3",
    "react-redux": "5.0.7",
    "redux": "^3.7.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "4.10.2",
    "redux-persist-crosstab": "^3.7.0",
    "reselect": "^3.0.1",
    "symbol-observable": "1.0.4"
  },
  "devDependencies": {
    "bootstrap": "3",
    "grunt": "1.0.3",
    "grunt-contrib-less": "^1.4.1",
    "grunt-contrib-watch": "1.1.0",
    "grunt-minify-html": "^3.0.0",
    "less-plugin-autoprefix": "^1.5.1",
    "less-plugin-clean-css": "^1.5.1",
    "npm-run-all": "4.1.3",
    "react-intl-cra": "0.3.3",
    "react-intl-po": "2.2.2",
    "react-scripts": "1.1.4"
  }
}
ghost commented 6 years ago

Actually, I get the same error even when I merge all of my dependencies under "dependencies" in package.json. I am using yarn v1.7.0.

I don't get this error in either situation when using npm v5.5.1.

sheepsteak commented 6 years ago

@waynebloss you say you have babel-runtime installed but I can’t actually see it in your dependencies.

I reckon yarn add babel-runtime will fix it.

ghost commented 6 years ago

@sheepsteak babel-runtime is a deep dependency of react-scripts, which I have in my devDependencies.

milesj commented 6 years ago

@waynebloss Peer dep requirements need to be explicitly defined, not implicit.

hulkish commented 6 years ago

i wonder if this pr may fix this. @rally25rs https://github.com/yarnpkg/yarn/pull/6012/files

panjiesw commented 6 years ago

Getting this issue with yarn v1.9.2. I haven't tried putting the deps in dependencies instead of devDependencies. According to #4743 it should have been fixed.

stdlo commented 6 years ago

I'm also affected over here. I'm also using lerna, however if I do a yarn install in each package without workspaces I don't get any warnings so I believe this is related.

node: v8.11.1 yarn: v1.7.0 lerna: 2.11.0

output:

yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > babel-jest@22.4.4" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > gateway > graphql-tools@3.0.2" has incorrect peer dependency "graphql@^0.12.0 || ^0.13.0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > glamorous@4.13.1" has unmet peer dependency "glamor@>=2".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > @storybook/addon-actions@3.4.7" has unmet peer dependency "@storybook/addons@^3.3.0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > @storybook/addon-links@3.4.7" has unmet peer dependency "@storybook/addons@^3.3.0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > @storybook/react@3.4.7" has unmet peer dependency "babel-core@^6.26.0 || ^7.0.0-0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > @storybook/react@3.4.7" has unmet peer dependency "babel-runtime@>=6.0.0".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > @storybook/react > babel-loader@7.1.4" has unmet peer dependency "babel-core@6".
warning "workspace-aggregator-bdf52bd9-faef-446f-a675-253d9ed02956 > client > redux-first-router-link@0.0.3-rudy" has incorrect peer dependency "redux-first-router@rudy".
[4/4] Building fresh packages...
sbonami commented 5 years ago

Bumping as this is still an issue in yarn 1.15

duro commented 5 years ago

Yea, I'm seeing this as well. We have our mono-repo broken into two workspaces. A services workspace, and a packages workspace. The projects in packages get imported into the services projects. We often want our packages to just define a peerDep for a certain library, so that the services have some flexibility on the exact version they install.

The problem I run into is that any package that defines a peerDep, ends up throwing a warning, depsite the face that the dep is also installed as a devDep in that package, and the service that imports it has the peerDep installed into it's main dependencies.

duro commented 5 years ago

This is a pretty serious annoyance as our project is growing. So many of our workspace packages depend on peerDeps that the list of warnings that mean nothing is growing and growing.

Window_and_2__adamduro_Duros-MacBook____Workspace_projects_freebird_serverless-mono__zsh_
loopmode commented 5 years ago

Just my two cents..: I wish I could mute these warnings by defining peerDependencies in the workspace root package.json.

The workspace is private anyways, it will not be consumed by any packages, so it's "peerDeendencies" field is basically unused. We could use it to define "nested peer dependencies", e.g. tell yarn and the workspace that these dependencies are somehow provided by workspace packages.

Whenever yarn would complain about a missing peer dependency, it could now check if the dependency in question is defined in the workspace peerDependencies, and if so, omit the warning.

TidyIQ commented 5 years ago

Bumping for update

lcswillems commented 5 years ago

Same issue for me. I checked my peer dependencies. They are correct but I get these warnings

maneetgoyal commented 5 years ago

Same issue :(

hjemmel commented 4 years ago

same issue here

antoine-malliarakis commented 4 years ago

Same issue here with yarn 1.21.1. And seems to be present also if the dependency is a production declared one.

MrCheater commented 4 years ago

+1

rikkit commented 4 years ago

Does anyone know if this is resolved with Yarn 2? I haven't made the switch yet but I would be OK with having to in order to fix this.

bertho-zero commented 4 years ago

@rikkit I no longer have this problem with Yarn 2, 0 warning.

Yarn 2 is more strict on the resolution of peerDependancies but allows to make optionalPeerDependencies and/or to overload the packages with missing peerDependencies.

damrem commented 3 years ago

same here with yarn@1.22.5

merceyz commented 3 years ago

Closing as fixed in v2

https://yarnpkg.com/getting-started/migration

diegodorado commented 2 years ago

Why is this closed? React Native projects do not play nicely with yarn 2, and all these warnings are annoying