【发布时间】:2020-04-22 20:48:29
【问题描述】:
我正在按照示例构建一个小型视频聊天:https://www.agora.io/en/blog/how-to-build-a-react-native-video-calling-app-using-agora
我通过以下方式创建了一个新项目:npx react-native init AwesomeProject
我添加了必要的依赖项:
npm install --save react-native-agora
npm install --save react-native-router-flux
npm install --save react-native-vector-icons
依赖也可以在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"
},
...
当我通过npx react-native run-ios 启动应用程序时,应用程序将在我的版本 10.2.1 (SimulatorApp-880.5 CoreSimulator-587.35) 上启动
我收到以下错误:Invariant Violation: Native module cannot be null. constructor NativeEventEmitter.js
我尝试使用npm install 重新构建它,构建成功。
我的猜测是我错过了将 react 链接到 react-native-agora。我尝试将其与react-native link react-native-agora 链接,但收到以下错误消息:
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.
提前致谢。
【问题讨论】:
-
我建议删除 node_module 并使用
rm -rf node_modules重新安装它们;npm installnpm 有时有问题
标签: ios reactjs react-native npm agora.io