Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Error w/ React-native : unable to resolve module http #111

Closed
philohelp opened this issue Apr 3, 2016 · 13 comments
Closed

Error w/ React-native : unable to resolve module http #111

philohelp opened this issue Apr 3, 2016 · 13 comments

Comments

@philohelp
Copy link

I get a red screen when I try to require Prismic. It says

Unable to resolve module http from .../node_modules/prismic.io/lib/requests.js: Invalid directory /Users/node_modules/http

I'm reaching the API directly with Fetch but SDK would have been appreciated.

Edit: no better results with 2.1.0 (saw the release comment on react-native). Now it says :
[error][tid:main] Unable to resolve module es6-promise from .../node_modules/prismic.io/lib/browser.js: Invalid directory /Users/node_modules/es6-promise
I got rid of that but then got the same error as with 2.1.3. Did the dirty job...

@erwan
Copy link
Contributor

erwan commented Apr 4, 2016

Hi,

It's a known issue, the RN loader will load the modules even if they're in a conditional.

I recommend you to use the compiled version in the meantime:
https://npmcdn.com/prismic.io@2.1.3/dist/prismic.io.js
https://npmcdn.com/prismic.io@2.1.3/dist/prismic.io.min.js

@philohelp
Copy link
Author

Ok many thanks for the quick reply. Would you have a short usage example on how it works with Fetch ?

P.S React being now more popular than JQuery, it would be great to have a specific kit (but I cant do it myself yet :-)

@erwan
Copy link
Contributor

erwan commented Apr 4, 2016

You actually don't have to use fetch, but it's used internally by the kit in order to work.

Here is a React (not native) example, but it should work the same:
https://github.com/erwan/react-starter

@philohelp
Copy link
Author

Quite exactly what I needed (and nice code), thanks !

@chandlervdw
Copy link

@erwan if I've got other teammates installing node_modules via npm, what's the best way to reference v3.2.0 so that I can utilize Prismic within my RN project?

@chandlervdw
Copy link

I found alw-react-native-prismic.io by @arnaudlewis which works with React Native! Hopefully that lib won't get shunned...

@arnaudlewis
Copy link
Member

A whole new version of the javascript-kit is close to be ready, it's designed to work in pair with the Prismic api v2 which handle default value to prevent null runtime exception. In this version, we will make sure that you can use it with react native out of the box. For this version of the kit, it can be consider to add support for react native but not in priority.

@scottbrassfield
Copy link

scottbrassfield commented May 24, 2017

Hi, I'm just hooking up Prismic to a RN project, and i wanted to check what is the currently recommended method of getting the SDK working with RN. I just installed prismic.io to my project and I am still getting the 'http' missing module error. Is the alw-react-native-prismic.io package mentioned above still the best way to get started?

@arnaudlewis
Copy link
Member

@scottbrassfield If you just started with prismic.io on this project, I suggest you to use the API V2 because you can manipulate the response as pure Json instead of calling functions from prototype like getImage etc.
You also have default values in the API to prevent null checking on the template part.
Finally, you can replace prismic.io by prismic-javascript which is perfect for API V2 and I made sure the fix I put in my lib alw-react-native-prismic.io are there in prismic-javascript so I think it's the best way.
So because of the new kit, I no longer maintain the other lib for React native.
If you need the API V2, tell me and I'll activate it for your repo and I'll explain you everything you need to know.

@scottbrassfield
Copy link

@arnaudlewis thanks for the quick response! I just replaced prismic.io with prismic-javascript in my project. If you could help me get started with API V2 that would be great, this is actually my first time using prismic.io in general so any help getting started with the API would be greatly appreciated.

@arnaudlewis
Copy link
Member

I'd be happy to help.
I can invite you on the prismic club, it's a slack channel with a dedicated part for the new API, I'll lead you from here.

@scottbrassfield
Copy link

Sounds great, just got the slack channel working, thanks!

@levimykel
Copy link
Contributor

This issue is resolved by using the prismic.io API v2 with the prismic-javascript kit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants