Skip to content

'ambiguous resolution module' when bundler compiling linked projects with both package.json contains same dependency #22471

Closed
@jerinho

Description

@jerinho

Environment (react-native info)

Environment:

  • OS: Windows 10
  • Node: 8.11.4
  • Yarn: 1.9.4
  • npm: 6.4.1

Packages: (wanted => installed)

  • react: 16.6.1 => 16.6.1
  • react-native: 0.57.7 => 0.57.7

Description

In a library project which is created using react-native-create-library, by default node_modules directory is not loaded up with packages including react and react-native. It's working just fine if we only do native coding. The problem is when we need to import and use a package to put some javascript code. Unable to resolve module signify that an application project never share it's module packages to the linked library project. Unfortunately, neither we can add a package to library project. When a project is linked to other project via symlink (on Windows the link is resided in C:\Users...\AppData\Local\Yarn\Data\link), all package.json file from each linked projects are not allowed to contains the same dependency among each other. If we compile in such condition, this error come out

bundling failed: ambiguous resolution: module C:\Users\USER\Desktop\test\index.js tries to require react, but there are several files providing this module. You can delete or fix them:

*C:\Users\USER\AppData\Local\Yarn\Data\link\react-native-mylibrary\node_modules\react\package.json
*C:\Users\USER\Desktop\test\node_modules\react\package.json

It's totally out of mind if we have to export native module via a limitable version of .js and we cannot even unlimit it. So I think it's seriously a bug which need to be debugged. Thank you

Reproducible Demo

  1. Follow this instructions https://facebook.github.io/react-native/docs/native-modules-android
  2. Let say you want to use module Component. From library project directory, yarn add react --save to add the package and import it from a .js
  3. react-native run-android from an application project directory and you'll meet the error

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugResolution: LockedThis issue was locked by the bot.Tech: Bundler 📦This issue is related to the bundler (Metro, Haul, etc) used.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions