【问题标题】:react-native link error 'Unknown dependency'react-native 链接错误“未知依赖项”
【发布时间】: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 install npm 有时有问题

标签: ios reactjs react-native npm agora.io


【解决方案1】:

我在 npm 上遇到了类似的问题,Nishant 评论尝试删除node_modules 文件夹并尝试npm installyarn install

【讨论】:

    猜你喜欢
    • 2020-02-18
    • 1970-01-01
    • 2017-12-23
    • 1970-01-01
    • 2021-12-05
    • 2021-12-08
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    相关资源
    最近更新 更多