When I run react-native link
on my RN project, I got below error:
$ react-native link
rnpm-install ERR! ERRPACKAGEJSON No package found. Are you sure it's a React Native project?
Cannot read property '_text' of undefined
I have searched that some people say run react-native upgrade
will resolve this issue. I have tried but no lock. My react version is shown as below:
$ react-native --version
react-native-cli: 2.0.1
react-native: 0.39.2
How can I solve this issue?
Follow below steps in order -
npm cache clean
or yarn cache clean
rm -rf node_modules
yarn install
or npm install
react-native upgrade
( You can choose no in all steps)react-native link
If you get permission related error use sudo
with all commands.
A little late but this may help someone else. My problem was large commented out copies of <manifest> ... </manifest>
in android/app/src/main/AndroidManifest.xml
. Once I removed commented out copies, link worked as expected.
It seems xmldoc
had touble parsing the manifest even though the AndroidManifest.xml was valid XML. Calling react-native link
uses ../node_modules/react-native/local-cli/core/android/index.js
. To debug such issues in future I would start with putting debugging statements in ../node_modules/react-native/local-cli/core/android/index.js
and narrow down to the root cause of the issue. Similar logic should work for ios.
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