React Native is a great library for building awesome applications.
But sometimes after downloading a project from Github or moving that project around from directory to directory, you’ll find that it throws off some reprehensible error.
This also seems to be common problem with projects that make use of Node Package Managers. So here are some of the steps you can take to troubleshoot this problem.
1. Delete the “node_modules” Folder
This is one of the crucial steps you should take especially when you have just downloaded a new React or React Native project.
The “node_modules” folder contains information about the library configurations that you have used for your project.
Some of these libraries are installed based on system configuration which apparently differs from system to system. So what you want to do is to delete that folder and re-install it
2. Run “yarn install” or “npm install”
Depending on whether you are using yarn or npm for your project (although yarn seems to be more favoured and recommended), after deleting your the “node_modules” folder, you should go to terminal and at the root of your project run the following command:
yarn install
//or
npm install
//Don't run both
Running any of the above command will immediately re-install the node_modules folder along with other specified dependencies in the package.json file.
3. Clear and Re-install Pods
The iOS version of your React Native project or app relies heavily on Cocoa-pods to manage all dependences used by your project.
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. You can read more about getting started with Cocopods here.
Meanwhile, for an already-existing project you can run the following command on your terminal:
cd ios
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod install
4. DebugManifest Failed Error
Sometimes when compiling your React Native project for Android, you’ll get the DebugManifest Failed Error.
This usually occurs because Jdk is not properly configured. What you can try is to check your jdk version and try to export it to your Java_home directory.
First, check for your jdk version:
/usr/libexec/java_home -V
Next, export to java_home directory:
export JAVA_HOME=`/usr/libexec/java_home -v 15.0.2` //replace with your correct version
Conclusion
React Native is a great library, but it’s also far from perfect (Do we really have perfect anything?)
More efforts and upgrades are being put in place to ensure it best serves its purpose, which is build native apps fast and easy.