Trying to link libraries (after adding react-native-config and after a full upgrade)
react-native link
Result
rnpm-install ERR! ERRPACKAGEJSON No package found. Are you sure it's a React Native project?
Cannot read property 'replace' of undefined
The package.json is there so the link should work
I'm experiencing a similar issue with react-native-config:
$ react-native link react-native-config
rnpm-install info Android module react-native-config is already linked
rnpm-install info Linking react-native-config ios dependency
rnpm-install ERR! It seems something went wrong while linking. Error: str.replace is not a function
Please file an issue here: https://github.com/facebook/react-native/issues
str.replace is not a function
I am experiencing the same issue with react-native-snackbar. Any fix for this?
@SandroMachado My fix was to manually link
I did the same :(
@SandroMachado It's sad that the more I work with react native, the more problems I find with the tooling.
Same issue. What is going on? I am having to manually link for now.
react-native-cli: 2.0.1
react-native: 0.43.3
@stilllife00 I think I may have found it. My issue was due to a missing package name in my debug AndroidManifest.xml file. Ensure your manifests have a valid package="com.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.<package>">
...
</manifest>
Your issue may be different, since it appears the cli just try...catch the whole loading process and throws this vague error if anything goes wrong. Here's the actual code that gave me a problem:
local-cli/core/android/index.js
L17: const getPackageName = (manifest) => manifest.attr.package; // <- Assumes package name attribute
…
L40: const packageName = userConfig.packageName || getPackageName(manifest);
const packageFolder = userConfig.packageFolder ||
packageName.replace(/\./g, path.sep); // <- Not nil safe
@tminard That actually did the trick. I was entirely missing the package attribute from the src/debug/AndroidManifest.xml
I had the same issue. Adding package to all AndroidManifest.xml files fixed it.
This issue can be closed
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.
I was experiencing the same issue. Turns out the developer had commented out the whole manifest and wrote the new manifest in the same file with the old version commented out at the bottom causing the same issue. I guess it is because of the package="com.
Cheers @bjacog, happened for me because I had something commented out at the bottom of my manifest (though not to do with package).
Most helpful comment
@stilllife00 I think I may have found it. My issue was due to a missing package name in my debug AndroidManifest.xml file. Ensure your manifests have a valid package="com." attribute:
Your issue may be different, since it appears the cli just
try...catchthe whole loading process and throws this vague error if anything goes wrong. Here's the actual code that gave me a problem:local-cli/core/android/index.js