找不到 requireNativeComponent 模块:无法解析“react-native-web/dist/exports/PermissionsAndroid”

requireNativeComponent Module not found: Can't resolve 'react-native-web/dist/exports/PermissionsAndroid'

提问人:Arnaud Girard 提问时间:10/13/2023 最后编辑:Arnaud Girard 更新时间:10/13/2023 访问量:219

问:

我正在使用 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} />
    );
  };
node.js react-native 错误处理 node-modules react-native-web

评论

0赞 Shivo'ham 10/13/2023
检查此 github.com/necolas/react-native-web/issues/...
0赞 Arnaud Girard 10/13/2023
我实际上发现 react-native-qrcode-scanner 现在存档在 github 上。有没有其他库做类似的事情。
0赞 Shivo'ham 10/13/2023
我想存档不是我们的问题
0赞 Arnaud Girard 10/14/2023
所以我尝试了他们的问题答案,但它对我不起作用,你有另一个想法来尝试解决这个问题吗
0赞 brianangulo 10/31/2023
嘿,@ArnaudGirard你有没有想过这个问题?

答: 暂无答案