提问人:Arnaud Girard 提问时间:10/13/2023 最后编辑:Arnaud Girard 更新时间:10/13/2023 访问量:219
找不到 requireNativeComponent 模块:无法解析“react-native-web/dist/exports/PermissionsAndroid”
requireNativeComponent Module not found: Can't resolve 'react-native-web/dist/exports/PermissionsAndroid'
问:
我正在使用 react native 并尝试使用
react-native-qrcode-scanner
(我还安装了 npm:react-native-camera 和 react-native-permissions)
我安装上述所有软件包的命令是: npm install module@latest --save
包读取QR码,但是当我尝试运行我的代码时,会弹出此错误:
ERROR in ./node_modules/react-native-camera/src/RNCamera.js:9:24
Module not found: Can't resolve 'react-native-web/dist/exports/PermissionsAndroid'
7 | NativeModules,
8 | ViewPropTypes,
> 9 | requireNativeComponent,
| ^
10 | View,
11 | ActivityIndicator,
12 | Text,
ERROR in ./node_modules/react-native-qrcode-scanner/index.js:4:35
Module not found: Can't resolve 'react-native-web/dist/exports/PermissionsAndroid'
2 |
3 | import React, { Component } from 'react';
> 4 | import PropTypes from 'prop-types';
| ^
5 |
6 | import {
7 | StyleSheet,
web compiled with 2 errors and 3 warnings
(我没有包括警告,因为我认为如果您确实需要它们,则不需要它们来解决问题,请告诉我我会更新它)
所以我的代码是从 Google 上的一个随机链接中提取的,我真的不记得是哪个了,但这是代码
import QRCodeScanner from 'react-native-qrcode-scanner';
const MyQRCodeScanner = () => {
const onSuccess = (e) => {
console.log(e.data);
// e.data contains the QR code data
};
return (
<QRCodeScanner onRead={onSuccess} />
);
};
答: 暂无答案
评论