为了澄清,我运行的是一台使用Android Studio的Windows计算机。
我正在尝试在react原生应用程序中使用react- native -camera设置二维码扫描器。
我可以毫不费力地安装库:
$ npm install react-native-camera --save
给出
npm WARN babel-eslint@10.0.1 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-eslint-comments@3.1.2 requires a peer of eslint@>=4.19.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-flowtype@2.50.3 requires a peer of eslint@>=2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jest@22.4.1 requires a peer of eslint@>=5 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-hooks@1.6.1 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename '[file location]\node_modules\.staging\fsevents-7a20bca6\node_modules\needle' -> '[file location]\node_modules\.staging\needle-41ea96cc'
+ react-native-camera@3.8.0
updated 1 package and audited 948127 packages in 76.202s
found 0 vulnerabilities我所见过的每一个在线参考资料,比如https://facebook.github.io/react-native/docs/linking-libraries-ios,似乎只有在你在Mac上为iOS编程时才会给出指导。
https://react-native-community.github.io/react-native-camera/docs/installation上的库的文档建议使用自动链接
$ react-native link react-native-camera。
我得到了:
info Linking "react-native-camera" iOS dependency
info iOS module "react-native-camera" has been successfully linked
info Linking "react-native-camera" Android dependency
info Android module "react-native-camera" has been successfully linked当我使用$ react-native run-android在我的设备上构建它时,问题出现了,我得到了:
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
- react-native-camera (to unlink run: "react-native unlink react-native-camera")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md手动链接的唯一结果是在XCode上,但是有谁可以帮助我使用Android Studio吗?我真的很感激。
发布于 2019-10-26 06:09:03
看起来您使用的是新版本的react-native (0.60或更高版本)。在这种情况下,您不必自己链接库,因为支持最新的react-native的库现在可以在安装时自行链接。
您应该能够执行npm install react-native-camera --save并使其正常工作。如果您以前使用过react-native link react-native-camera,现在可能需要运行react-native unlink react-native-camera来恢复通过link命令执行的操作。您可能还需要重新安装库(先安装npm uninstall react-native-camera,再安装npm install react-native-camera --save)。如果它仍然不起作用,你可以通过manual installation of this library
https://stackoverflow.com/questions/58566060
复制相似问题