I created a npm libary using react-native-create-library. I can publish the newly created library into npm. But as I developing, I'm not able to test it locally with a react-native project.
If I tried to add by adding the file path to dependancy section of package.json then I'm getting this error
error: bundling failed: Error: Unable to resolve module
react-native-test-library-abcd-onefromC:\Users\kk\TestLibABCD1\LibraryTester\App.js: Modulereact-native-test-library-abcd-onedoes not exist in the Haste module map
It will work if I do a npm install react-native-test-library-abcd-one.
How can I link my local libaray in this case?
You should use the git clone url set against the library name in your package.json.
Thats how incrementally the bigger softwares/libraries are developed You should versionize it using git or something else. :)
That should look like:
"react-native-touch-id": "https://github.com/surajj2223/react-native-touch-id.git"
If that would not have been your library then a simple use case where such thing is needed: You alter some code as per your need in some specific library so you have your own version of the library now and upon next npm install/yarn install you lose your changes if you have not uploaded that on git.
So what can be done is,
package.jsonnpm install/yarn install and you are good to go now.And if you make some really generic changes that others would also be needing then its always better to make a pull request to the original library and get it merged thereby helping the community too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With