Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Fresh new install gives unmet peer dependencies warnings with yarn #3394

Closed
htulipe opened this issue Aug 20, 2019 · 14 comments
Closed

Fresh new install gives unmet peer dependencies warnings with yarn #3394

htulipe opened this issue Aug 20, 2019 · 14 comments

Comments

@htulipe
Copy link

htulipe commented Aug 20, 2019

Intended outcome:

I tried to start a new Apollo project, based on the documentation I issued:

yarn add react react-dom apollo-boost @apollo/react-hooks graphql

Which gave:

warning "@apollo/react-hooks > @apollo/react-common@3.0.1" has unmet peer dependency "@types/react@^16.8.0".
warning "@apollo/react-hooks > @apollo/react-common@3.0.1" has unmet peer dependency "apollo-client@^2.6.4".
warning "@apollo/react-hooks > @apollo/react-common@3.0.1" has unmet peer dependency "apollo-utilities@^1.3.2".
warning " > @apollo/react-hooks@3.0.1" has unmet peer dependency "@types/react@^16.8.0".
warning " > @apollo/react-hooks@3.0.1" has unmet peer dependency "apollo-client@^2.6.4".

Actual outcome:

I would expect either no warnings or those peer deps being mentioned in the documentation

Note that with npm instead of yarn, I only get those warnings:

npm WARN @apollo/react-hooks@3.0.1 requires a peer of @types/react@^16.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollo/react-common@3.0.1 requires a peer of @types/react@^16.8.0 but none is installed. You must install peer dependencies yourself.

How to reproduce the issue:

yarn init
yarn add react react-dom apollo-boost @apollo/react-hooks graphql

Version

System:
    OS: macOS 10.14.5
  Binaries:
    Node: 10.14.2 - ~/.nvm/versions/node/v10.14.2/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.14.2/bin/npm
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 68.0.2
    Safari: 12.1.1
  npmPackages:
    apollo-boost: ^0.4.4 => 0.4.4
@vemundeldegard
Copy link

Experiencing the same. I'm using yarn.

@rhoskal
Copy link

rhoskal commented Aug 23, 2019

Respectfully, I would classify this as desired behavior. Open source packages commonly specify peer dependencies and yarn/npm is being helpful with these warning messages e.g. doing a yarn add react-dom would result in a warning " > react-dom@16.9.0" has unmet peer dependency "react@^16.0.0". You are experiencing similar behavior here where the @apollo/react-hooks package in the monorepo specifies its own peer dependencies. Older version on yarn/npm used to automatically install peer deps but that caused complications which is why the community has moved away from it.

@htulipe
Copy link
Author

htulipe commented Aug 23, 2019

I see your point @hansjhoffman though I would argue the documentation of React states that you have to install react alongside react-dom. It's not the case for Apollo's doc.

That put aside, it's strange that yarn and npm does not results in the same missing peer deps (though it's more their problem than Apollo's).

@hwillson
Copy link
Member

hwillson commented Sep 6, 2019

As mentioned in #3394 (comment), this is desired behavior. This is all going to change very soon when React Apollo is merged into the Apollo Client project. Thanks!

@hwillson hwillson closed this as completed Sep 6, 2019
@htulipe
Copy link
Author

htulipe commented Sep 6, 2019

So the idea for now is for me to add every peer deps to my project, ie "@types/react@^16.8.0", "apollo-client@^2.6.4" and "apollo-utilities@^1.3.2". Correct @hwillson ?

@Tylerian
Copy link

Tylerian commented Oct 21, 2019

Thing is yarn complains even when the required peer dependencies are already installed if the version is mismatching.

for example in my project I'm using react@latest(16.10.2) and the following shows in yarn:
warning " > @apollo/react-hooks@3.1.3" has unmet peer dependency "react@^16.8.0".

Is this desired behavior?

@robbertkl
Copy link

For me, I'm getting warnings about typescript peer dependencies, which I'm not using:

npm WARN @apollo/react-common@3.1.3 requires a peer of @types/react@^16.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollo/react-hooks@3.1.3 requires a peer of @types/react@^16.8.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

So @apollo/react-common and @apollo/react-hooks list @types/react as a peerDependency. I think the warning about tsutils seems to come from another package, unrelated to apollo.

@mxmlnglt
Copy link

As mentioned in #3394 (comment), this is desired behavior. This is all going to change very soon when React Apollo is merged into the Apollo Client project. Thanks!

What is the timing of this "very soon"...?

@simkessy
Copy link

To simplify things, do I need to install these for things to work or not. That's all I need to know.

@Satish-A-Wadekar
Copy link

npm root -g
go to global packages
open package.json
find the "peerDependencies" and add ^ on respective npm pckg
and you are done

@bkarlson
Copy link

or simply cleaning global node_modules dir (in case you don't need global packages any longer) also helped

@leonaves
Copy link

To simplify things, do I need to install these for things to work or not. That's all I need to know.

@hwillson

@millievn
Copy link

millievn commented Mar 1, 2020

To simplify things, do I need to install these for things to work or not. That's all I need to know.

@hwillson
That's what i really want to know

@hwillson
Copy link
Member

hwillson commented Mar 1, 2020

The answer is a bit complicated (which is why we're super excited to finally merge parts of this project into Apollo Client). The most important peer dep to have is apollo-client, but if you're using apollo-boost for example, you should already have it as a transitive dependency (so you can ignore that warning). @types/react is only needed if you're using Typescript, and it's listed as a peer dep because of the issue outlined in #3278.

If you're just using React Apollo's hooks, I suggest trying out the Apollo Client 3 beta (@apollo/client@beta) which doesn't have any of these issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests