axios: Unable to resolve axios module with RN 0.40.0 [Android]

The new 0.40.0 release of RN has broken axios for me. I’ve done two test cases in which I create a blank application, install axios, then import axios on the index page. The only difference between the two projects are the RN version number.

react-native init TestProject (this is @latest which is currently 0.40.0) cd TestProject npm install axios --save I then go into the index.android.js file and add: import axios from 'axios' react-native run-android In this case, I get the following error: Unable to resolve module http from C:\ReactNative\Projects\TestProject\node_modules\axios\lib\adapters\http.js: Module does not exist in the module map or in these directories: C:\ReactNative\Projects\TestProject\node_modules.

However, when I install an older version of RN like below, axios works fine. rninit init TestProject --source react-native@0.39.2 cd TestProject npm install axios --save I then go into the index.android.js file and add: import axios from 'axios' react-native run-android

As a workaround to fix this I have downgraded my RN back down to 0.39.2 rather than using 0.40.0.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 25 (2 by maintainers)

Most upvoted comments

+1 If you’re doing some sort of tutorial like me you can use fetch instead of axios, check it here https://facebook.github.io/react-native/docs/network.html