Description
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
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
- Follow this instructions https://facebook.github.io/react-native/docs/native-modules-android
- 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
react-native run-android
from an application project directory and you'll meet the error
References
- https://stackoverflow.com/questions/53537990/react-native-from-a-library-project-how-to-import-and-use-a-packages-module
- error: bundling failed: ambiguous resolution: module .../index.js tries to require react-native, but there are several files providing this module. You can delete or fix them frostney/react-native-create-library#89