react-native link error 'Unknown dependency' - ios

I'm following the example to build a small video chat: https://www.agora.io/en/blog/how-to-build-a-react-native-video-calling-app-using-agora
I created a new project via: npx react-native init AwesomeProject
I added the necessary dependencies:
npm install --save react-native-agora
npm install --save react-native-router-flux
npm install --save react-native-vector-icons
The dependencies can be also seen in the package.json
...
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-agora": "^2.9.1-alpha.2",
"react-native-router-flux": "^4.0.6",
"react-native-vector-icons": "^6.6.0"
},
...
When i start the app via npx react-native run-ios the app will start on my Version 10.2.1 (SimulatorApp-880.5 CoreSimulator-587.35)
I get the following error: Invariant Violation: Native module cannot be null. constructor NativeEventEmitter.js
I tried rebuilding it with npm install and the build was successful.
My guess is that i missed linking react to react-native-agora. I tried to link it with react-native link react-native-agora but i get the following error message:
error Unknown dependency. Make sure that the package you are trying to link is already installed in your "node_modules" and present in your "package.json" dependencies.
Thanks in advance.

I had a similar problem with npm, as Nishant commented try deleting the node_modules folder and try npm install or yarn install.

Related

error React Native CLI uses autolinking for native dependencies - RN iOS

I'm new to React native. I get the following error when I try to start the project in the ios simulator. How can I solve this?
Newer versions of React Native have autolinking, therefore you don't need to run commands like npx react-native link some-package-name to link the dependencies
In order to get rid of this error you need to unlink the dependency mentioned in the log, use the following instructions
Run npx react-native unlink #react-native-async-storage/async-storage
Run npm uninstall #react-native-async-storage/async-storage
Run npm install #react-native-async-storage/async-storage
Change to the ios directory cd ios and run pod install
That should solve this issue

React Native - Failed to load bundle in iOS

I am native iOS app developer but i also want to be aware of latest and trending technology so i choose to get my hands on react native. Now, i am getting this error when trying to run my react native created app on iOS. I enter the command react-native run-ios and simulator started and after that app opened but in starting it showed this screen.
There are couple of solutions available in the link below. Please try them.
https://github.com/facebook/react-native/issues/21310
for now after react-native init, since a lot of new changes are coming out, this fix worked for me (I got it from reading other issues):
with npm:
npm install --save-dev #babel/core
npm install --save-dev #babel/runtime
or with yarn:
yarn add --dev #babel/core
yarn add --dev #babel/runtime
if on ios you get _this._registerEvents is not a function, after a successful build
do
npm run start --reset-cache
or
react-native start --reset-cache
For me i got reason for issues that for now since a lot of new changes are coming out like Xcode 10 itself is new and react native is not yet merged with that, this fix worked for me:
with npm:
npm install --save #babel/runtime
or with yarn:
yarn add #babel/runtime

Invariant Violation: Native component for "RNSVGSvgView" does not exist

After days of research on the internet I still haven't solved my problem yet.
I am using react-native-svg and I am having the same issues:
No component found for view with the name "RNSVGPath"
Or this one:
Invariant Violation: Native component for "RNSVGSvgView" does not exist
I tried a lot of things, including:
react-native unlink react-native-svg
npm uninstall react-native-svg
npm install react-native-svg
react-native link react-native-svg
react-native run-ios
Also:
pod 'RNSVG', :path => '../node_modules/react-native-svg'
rm -rf node_modules
npm install
react-native run-ios
But still nothing...
Here's the versions I am using:
"dependencies": {
"react": "16.1.1",
"react-native": "0.50.3",
"react-native-svg": "^6.0.1-rc.1"
}
I tried to build it from XCode directly and still nothing...
Thanks for your help guys !
You should try to do this:
npm install react-native-svg --save //(again)
react-native link react-native-svg //(again)
watchman watch-del-all
rm -rf node_modules/ && yarn cache clean && yarn install
Then in another terminal
npm start -- --reset-cache
Before starting your ios app with react-native run-ios, you have to add libRNSVG.a manually to your Linked Frameworks and Libraries in Xcode
And then ... Tada
SVG Problem, I also stuffed 4 hours and get the solution.
Automatic link:
react-native link react-native-svg
Does not work automatically then you do with manually.
Manual Link:
1 Append the following lines to android/settings.gradle:
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
2 Insert the following lines inside the dependencies block in android/app/build.gradle:
implementation project(':react-native-svg')
3 Open up `android/app/src/main/java/[...]/MainApplication.java
Add import com.horcrux.svg.SvgPackage; to the imports at the top of the file.
Add new SvgPackage() to the list returned by the getPackages() method. Add a comma to the previous item if there's already something there.
I had this problem because "react-native link" is broken as of RN 0.51. Linking manually after complete removal and reinstall fixed it on iOS.
Svg have problem with version
first, unlink svg then remove npm of svg then install new one
"dependencies": {
"react": "16.1.1",
"react-native": "0.44.0",
"react-native-svg": "5.1.8"
}
I had the same issue but on Android.
So, if you are in the same conditions, here is something that fixed it, the trouble happened specifically on MainApplication, so you want to look at :
open android/app/src/java/com/*/MainApplication.java
add import com.horcrux.svg.SvgPackage; on top with other imports
add new SvgPackage() along the others in the list getPackages() (~line 30-ish)

React-native#0.26.3 requires a peer of react#15.0.2 but none was installed

I am trying to set up for the react native. but whenever I update files it gives m error
enoent ENOENT: no such file or directory, open 'React Native/package.json'
npm WARN react-native#0.26.3 requires a peer of react#15.0.2 but none was installed.
npm WARN React Native No description
npm WARN React Native No repository field.
npm WARN React Native No README data
npm WARN React Native No license field.
MacBook-Pro:React Native$ npm info react dist-tags.latest
Please let me know how can I fix.
Installing react should fix the error
npm install react --save
Also, you may try upgrading your react-native install. react-native is as v0.30.0 now
npm update react-native
In my specific case I was running npm install in the wrong directory. I thought I was in my project directory but was one level higher. This meant react was missing from installed packages (because there were none) and thus gave this error.
Some steps that worked for me:
1. watchman watch-del-all
2. rm -rf node_modules
3. npm install react#15.0.2 --save
4. npm install react#15.1.0 --save
5. npm install
6. rm -fr $TMPDIR/react-*
7. npm start -- --reset-cache
In my case, the project I am working on requires a specific version of React. Since it was older than the current release, doing an install/update would still cause the error.
In order to fix the problem, I had to check the package.json of the project and install the exact version allowed by the dependency definition. In the OP's case, a
npm install react#15.0.2
should fix the problem by installing the exact version of the React module that react-native requires.
Verify that the condition was resolved by doing a npm list to see if there are any other unmet peer dependencies.

isActive lib cannot be found

i am building an app that uses react-router,flux and i found this library called redux-auth(https://github.com/lynndylanhurley/redux-auth). I am trying to use it since it has a lot of work done regarding loging,sign up, etc.
I installed the dependencies with npm in this order - >
npm install redux-auth --save
npm install material-ui --save
npm install react-tap-event-plugin
After this i got the error i mention, the module isActive cannot be found.
So i searched the web and found this post:
https://github.com/acdlite/redux-router/issues/111
Where they fix it with this command: npm install --save history react-router#latest followed by npm install --save redux-router#1.0.0-beta3
After this my app broke, and now i get the error : "Error: ajax not supported in this browser" when prerendering Router with / and {}
The line with such error: <%= react_router 'Router', 'HistoryLocation', {}, { prerender: params[:noprerender].nil?, prerender_location: root_path } %>
Tried uninstalling such libraries but didn't work out, tried removing the node_modules dir and rebuilding with npm but didn't work.
Any help or advice? is impossible for me to use this library? is it maybe a compability problem between flux and redux? Any help is welcome.
Edit #1 : I am using Chrome.

Resources