Closed
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
(If I doing this, I doubt I will get here to submit this issue 😆 )
Environment (react-native info
)
Environment:
- OS: Windows 10
- Node: 8.11.4
- Yarn: 1.9.4
- npm: 6.4.1
- Watchman: Not Found
- Xcode: N/A
- Android Studio: Not Found
Packages: (wanted => installed)
- react: 16.3.1 => 16.3.1
- react-native: 0.55.4 => 0.55.4
Description
In a library project, how actually the proper way to install or simply and directly use a module package?
Reproducible Demo
- https://facebook.github.io/react-native/docs/native-modules-setup
- https://facebook.github.io/react-native/docs/native-modules-android
- By default a library project does not loaded up with any packages including
react
andreact-native
. So errorUnable to resolve module
will come out when you trying to import it in a.js
- Let say you want to use module
Component
. Try to add packageyarn add react --save
and import it from a.js
react-native run-android
from a linked application project directory- I'll jump off the bridge if you never get this error
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
What have you (me) tried ???
- Still waiting for an answer from https://stackoverflow.com/questions/53537990/react-native-from-a-library-project-how-to-import-and-use-a-packages-module
- This repo is useless in my case. But at least it speed up your work bringing you to the same error. If you know how to follow the instruction properly. 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
Please. I know the why I found this error. But that's not the answer I wanna know. I'm just looking for how to install and use a package in linked external project. That's all. Nothing more and nothing less 😄