RNDocumentPicker:本机模块不可用

时间:2019-02-10 02:19:27

标签: javascript react-native

我完全按照此处(https://github.com/Elyx0/react-native-document-picker/issues/94?fbclid=IwAR2Ke7ejhPYaJcT0bS7jTZHbZvXM570C7aHQQRAvHQz56C9qzvf3W1R5SkA)的说明进行操作,但是它不起作用。我收到此错误:

RNDocumentPicker: Native module is not available, make sure you have finished the installation process and rebuilt your app


Error: not opened
at WebSocket.send (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:219:16)
at send (/Users/miajohansson/Desktop/bnook/node_modules/react-native/local-cli/server/util/webSocketProxy.js:26:12)
at WebSocket.debuggerSocket.onmessage (/Users/miajohansson/Desktop/bnook/node_modules/react-native/local-cli/server/util/webSocketProxy.js:48:48)
at WebSocket.onMessage (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:442:14)
at emitTwo (events.js:126:13)
at WebSocket.emit (events.js:214:7)
at Receiver.ontext (/Users/miajohansson/Desktop/bnook/node_modules/ws/lib/WebSocket.js:841:10)
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/Receiver.js:536:18
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/Receiver.js:368:7
at /Users/miajohansson/Desktop/bnook/node_modules/ws/lib/PerMessageDeflate.js:249:5

当我在下面的代码中添加DocumentPicker时,出现TypeError:无法读取已定义的属性“ show”。

import { DocumentPicker, DocumentPickerUtil } from 'react-native-document-picker';

// iPhone/Android
DocumentPicker.show({
      filetype: [DocumentPickerUtil.images()],
    },(error,res) => {
      // Android
      console.log(
         res.uri,
         res.type, // mime type
         res.fileName,
         res.fileSize
      );
    });

我已经删除了node_modules并运行npm install,但是仍然出现此错误。

1 个答案:

答案 0 :(得分:1)

请问您是在哪个安装,npm 还是yarn,安装没有完成。尝试重做 yarn add react-native-document-picker --savenpm install react-native-document-picker --save