8

Disclaimer

I have looked at the trouble shooting page of the wiki, however I still cannot fix the problem I am having.

RN version:

react-native-cli: 2.0.1
react-native: 0.43.4

My code:

import FileUploader from 'react-native-file-uploader'

and

<Button
    onPress={() => RNFetchBlob.fetch('POST', 'http://localhost:8000/upload', {
            'Content-Type' : 'application/octet-stream'
        }, RNFetchBlob.wrap('./tempImageStore/image.jpg'))
    }
    title={'Upload File'}
/>

Error I am getting:

simulator screen shot may 7 2017 11 04 09 am

What I did to install react-native-fetch-blob:

1) npm install --save github:wkh237/react-native-fetch-blob-package#master
2) react-native link

Background info:

  • I have tried importing it with both import RNFetchBlob from 'react-native-fetch-blob' and var RNFetchBlob = require('react-native-fetch-blob').default
  • I have tried installing it with the above code and also with npm install --save react-native-fetch-blob
  • I am trying this on the IOS emulator.

Thank you in advance for your help!

zoecarver
  • 5,523
  • 2
  • 26
  • 56
  • hey thanks for the question. but how did you make it work with cocopod please? – MartianMartian Aug 14 '17 at 15:17
  • The problem is with react-native link command. It is not linking the RNFetchBlob. Follow these instructions to fix it: https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package – Mathioli Ramalingam Apr 23 '18 at 20:42

5 Answers5

5

After linking you need to run

pod update

inside ios folder

Krishan Kumar Mourya
  • 2,207
  • 3
  • 26
  • 31
2

So it looks like the module isn't importing. Obvious I know, I can only think of a few things to help seeing as that project looks fairly popular and stable.

I noticed that you're requiring 'react-native-file-uploader' but using 'react-native-fetch-blob'. I'm assuming this is a mistake. You could also try, if you haven't:

var RNFetchBlob = require('react-native-fetch-blob')

Now assuming you're correctly importing it, try one of the following and then restart x-code:

  1. If you haven't already restart the packager. I recall having to restart the packager every time I installed a new module.

  2. If that doesn't work, try installing deleting it from your node modules (just to be safe) and installing with cocoa pods which will handle all of the linking for you.

klvs
  • 1,074
  • 6
  • 21
  • I re-built the project and used cocoa pods. This worked. Thank you for the help, I will award you the 50 points in a day or two if no one else submits something that works better. Thank you again for the help. – zoecarver May 12 '17 at 01:52
  • Sure, no problem. I do think it should work without cocoapods but can't offer an explaination as to why it doesn't without dig much much deeper. – klvs May 12 '17 at 08:19
  • @zoecarver I understand that in order to install with cocoa pods you add the package to podfile, right? How do you do it? – Yossi Apr 29 '20 at 08:17
  • @klvs Why did you write 'try installing/deleting'? Not just deleting by npm/yarn and installing with cocoa pods? – Yossi Apr 29 '20 at 08:17
  • And one more thing: why is it required to install this package with cocoa pods while the others are installed with npm/yarn? – Yossi Apr 29 '20 at 08:40
2

If you are using React Native >= V.060 nothing to do

If you are using React Native <= 0.59

Check this link : https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package

Mustapha GHLISSI
  • 1,485
  • 1
  • 15
  • 16
0

Is part 2 of the installation actually

react-native link

? I think it should be

react-native link github:wkh237/react-native-fetch-blob-package#master
  • i am facing same error on android. Were you able to run on android? I tried almost all solution but it didn't worked. please let me know if it working for you. – ruyamonis346 Apr 03 '18 at 21:47
0

first it has changed to rn-fetch-blob https://github.com/joltup/rn-fetch-blob

then when you install it then Do the linking manually, it worked for me

https://github.com/joltup/rn-fetch-blob/wiki/Manually-Link-Package

Ala'a
  • 75
  • 1
  • 4
  • 2
    A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – double-beep Mar 26 '19 at 16:54