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

Issue with Yarn 2 and strict module checking #1015

Closed
wdfinch opened this issue Mar 19, 2021 · 10 comments
Closed

Issue with Yarn 2 and strict module checking #1015

wdfinch opened this issue Mar 19, 2021 · 10 comments
Assignees

Comments

@wdfinch
Copy link

wdfinch commented Mar 19, 2021

After upgrading to yarn 2, I'm getting the following compile-time error while trying to start a create-react-app application:

Module not found: react-flow-renderer tried to access react-dom, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

I believe this is because yarn 2 only gives access to what's required as a dependency or peer dependency. I'm not sure if this would work, but adding react-dom as a peer dependency might help here.

@moklick
Copy link
Member

moklick commented Mar 19, 2021

This is weird. React Flow doesn't need react-dom. But thanks for the hint. We will check it.

moklick added a commit that referenced this issue Mar 19, 2021
@moklick
Copy link
Member

moklick commented Mar 19, 2021

Can you check v9.3.0?

@wdfinch
Copy link
Author

wdfinch commented Mar 20, 2021

Just checked. Seems to be working fine now. Thanks for the quick patch @moklick.

@wdfinch wdfinch closed this as completed Mar 20, 2021
@wdfinch wdfinch reopened this Mar 22, 2021
@wdfinch
Copy link
Author

wdfinch commented Mar 22, 2021

Just had a relook at this and it seems there are also issues with the type declaration files for react-redux and d3.

The error looks like this:

.yarn/$$virtual/react-flow-renderer-virtual-1f7b0210b1/0/cache/react-flow-renderer-npm-9.3.0-185ae10f59-07abdc5493.zip/node_modules/react-flow-renderer/dist/types/index.d.ts(2,56): error TS2307: Cannot find module 'd3' or its corresponding type declarations.

I think the issue is these types are referenced by the package in .d.ts files, however, they are listed as dev dependencies and therefore are not present in the version that is installed from npm. Therefore, when types are imported via the .d.ts files, yarn 2 will throw an error as it cannot find the type definitions for these libraries. Not sure how would want to fix this. My solution is to add

packageExtensions:
  "react-flow-renderer@*":
    dependencies:
      "@types/react-redux": "*"
      "@types/d3": "*"

to my .yarnrc.yml file and therefore add them in as dependencies.

@moklick
Copy link
Member

moklick commented Mar 28, 2021

Thanks. Can you check v9.4.0?

@wdfinch
Copy link
Author

wdfinch commented Mar 29, 2021

Looks good now. Thanks!

@poicooler
Copy link

I think this commit 51a1fd5 broke this fix.

@moklick moklick reopened this Mar 9, 2022
@moklick moklick self-assigned this Mar 9, 2022
@richxcame
Copy link

I think this commit 51a1fd5 broke this fix.

I agree with you. I have same problem!

@moklick
Copy link
Member

moklick commented May 23, 2022

I am not able to reproduce this. My steps are:

  • yarn create react-app my-app
  • cd my-app
  • yarn add react-flow-renderer
  • yarn start

@moklick
Copy link
Member

moklick commented Aug 16, 2022

added to dependencies in v10.3.15

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

4 participants