Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid dependencies inside nested node_modules #4590

Closed
alansouzati opened this issue Sep 29, 2017 · 8 comments
Closed

Invalid dependencies inside nested node_modules #4590

alansouzati opened this issue Sep 29, 2017 · 8 comments

Comments

@alansouzati
Copy link

alansouzati commented Sep 29, 2017

This is my package.json:

{
  "dependencies": {
    "grommet-icons": "^0.9.0",
    "enzyme": "^3.0.0",
    "enzyme-adapter-react-16": "^1.0.0",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-test-renderer": "^16.0.0"
  }
}

grommet-icons library still uses React 15.X, while enzyme and enzyme-adapter-react-16 uses React 16. enzyme-adapter-react-16 has a dependency on enzyme-adapter-utils which has the following values for peerDependencies:

  "peerDependencies": {
    "react": "0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0"
  },

When I run npm install I have the following structure inside my node_modules:

- node_modules
  - grommet-icons
    - node_modules
      - react (version 15)
      - react-dom (version 15)
  - enzyme-adapter-utils (**no node_modules folder**)
  - enzyme-adapter-react16
  - react
  - react-dom

This feels right to me and I can run my application tests without any problems.

On the other hand, when I run yarn install I get a different output:

- node_modules
  - grommet-icons
    - node_modules
      - react (version 15)
      - react-dom (version 15)
  - enzyme-adapter-utils
    - node_modules
      - react (version 15)
  - enzyme-adapter-react16
  - react
  - react-dom

This is breaking enzyme with the following output:

this.updater.enqueueCallback is not a function

Manually removing the enzyme-adapter-utils/node_modules/react resolves the problem.

I believe Yarn is resolving peerDependencies differently than NPM. It seems to me that YARN finds the first match anywhere in the dependency tree (notice that React 15 is NOT a peerDependency of enzyme-adapter-utils).

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

Report a bug

What is the current behavior?

Yarn uses React 15 as a peerDependency of enzyme-adapter-utils

What is the expected behavior?

Yarn should not use React 15 as a peerDependency of enzyme-adapter-utils

To reproduce this problem just run npm install and check the content of node_modules/enzyme-adapter-utils. You can see that there is no node_modules folder. When running yarn install this folder will be present with react 15 inside it.

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

Node: 6.11.x
Yarn: 1.1.0
OSx 10

@IanVS
Copy link

IanVS commented Oct 2, 2017

I can confirm similar behavior beginning in yarn 1.1.0.

I am using:

  • react@15.4.2 in my own application
  • flow-coverage-report which depends on react@15.3.1
  • react-router-dom which has a peerDependency on react@>=15

I find that with yarn 1.0.2, there is no react in the node_modules of react-router-dom, but when using yarn 1.1.0, then react@15.3.1 ends up in its node_modules, which causes my application to crash (only in dev, luckily) saying there are more than one react versions loaded.

@IanVS
Copy link

IanVS commented Oct 2, 2017

This seems to be related to (a duplicate of?) #4539

@karak
Copy link

karak commented Oct 13, 2017

I met similar problem using @types packages, type definition files of TypeScript.
Minimum set is HERE.

This behavior is harmful and so confusing.

@IanVS
Copy link

IanVS commented Oct 13, 2017

I think this can be closed now that yarn 1.2.1 is released. It has fixed the problem in my case at least.

@karak
Copy link

karak commented Oct 13, 2017

@IanVS Then, I simply need another issue. Yarn 1.2.1 don't resolve my issue. You can reproduce that within a few minutes from my link.

@IanVS
Copy link

IanVS commented Oct 13, 2017

@karak, yeah, I'd recommend opening another issue, because I don't think it's related to this one.

@karak
Copy link

karak commented Oct 13, 2017

@IanVS I did it, thank you.

@alansouzati
Copy link
Author

updating to 1.2.1 does fix the issue.

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

No branches or pull requests

3 participants