Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requiring npm modules fails #375

Closed
markthethomas opened this issue Mar 28, 2015 · 10 comments
Closed

requiring npm modules fails #375

markthethomas opened this issue Mar 28, 2015 · 10 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@markthethomas
Copy link

Was hoping to try out using something like request or superagent (as suggested in docs) to handle network calls, but when I npm install -S them, I get requiring unknown module [MODULE_NAME] for both superagent and request. Could it be that the deps for each required module aren't being recursively looked at? Is this expected behavior And, furthermore, is there a best way to go about requiring modules for React-Native specifically that would differ from a more straightforward/typical JS use-case?

example thrown error for require('request') or related npm modules
tbhp8x_qovrt0mo09jvfjsy8fcz4knf4jnwcpxcxotm

@markthethomas markthethomas changed the title requiring NPM modules fails requiring npm modules fails Mar 28, 2015
@aackerman
Copy link

For this specific case you'll likely want to use the fetch API which is provided by the environment. React Native does not run inside of the node runtime.

@markthethomas
Copy link
Author

Yeah, had a major "doh" moment after posting. But superagent and most browser friendly modules should work, no?

@chetstone
Copy link
Contributor

I'm having this issue trying to require fluxxor. After doing npm install fluxxor

untitled

vjeux pushed a commit to vjeux/react-native that referenced this issue Apr 13, 2015
Summary:
Apparently we promote using superagent but it doesn't actually work. See issues facebook#370 facebook#10 facebook#375
The main issue stopping it from working is the `browser` field in package.json which both browserify and webpack implments.
This implements most of the spec found here https://gist.github.com/defunctzombie/4339901
The only thing we're not implementing is the `module-name: false` part to ignore a module because it doesn't seem to be as used. If someone complains about it we'll implement it then.

Test Plan:
./runJestTests.sh
* npm install superagent in JS
* test using superagent
@fselcukcan
Copy link

What? Isn't it supoorted to use ordinary npm modules in a react native project by simply npm installing.
For example npm install socket.io.

@markthethomas
Copy link
Author

It is, but not the ones that rely on a node runtime environment.

@fselcukcan
Copy link

Huh! Thanks, I am really relaxed, serious.

@fselcukcan
Copy link

What was the problem when you were installing superagent or request?

@niftylettuce
Copy link
Contributor

Was this resolved?

@maluramichael
Copy link

@markthethomas then how do i use other modules like lodash or xml2js?

@SudoPlz
Copy link
Contributor

SudoPlz commented Nov 1, 2016

@isikfsc The problem when I installed request was that it used dependencies like require('os') or require('crypto') that were simply not there, since the environment was not a node environment.

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

8 participants