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

Running rn-nodeify breaks node_modules #42

Closed
you-fail-me opened this issue Jul 5, 2017 · 15 comments
Closed

Running rn-nodeify breaks node_modules #42

you-fail-me opened this issue Jul 5, 2017 · 15 comments

Comments

@you-fail-me
Copy link

you-fail-me commented Jul 5, 2017

After running ./node_modules/.bin/rn-nodeify --install --hack it does some weird thing to my react-native dep (turns the folder under node_modules into a bunch of empty folders):
screen shot 2017-07-05 at 10 41 45 am
I thought it was something with yarn, but no, if I don't run rn-nodeify it's ok. Why? How can I fix?

@mvayngrib
Copy link
Member

@you-fail-me pretty strange, haven't experienced this myself. Care to investigate and submit a PR?

@you-fail-me
Copy link
Author

@mvayngrib I'm trying to investigate that but some help, suggestions, advice etc would be very helpful.

@mvayngrib
Copy link
Member

@you-fail-me absolutely. The gist is:

the --install part
crawls the project using the findit module and potentially modifies all the package.json files in the node_modules tree (with fs.writeFile), as well as the project's own package.json. It then runs npm install --save list,of,core,shims, e.g. npm install stream-browserify,react-native-crypto to install missing shims for core modules.

the --hack part
goes through node_modules and patches modules that the react-native packager chokes on but webpack and browserify don't, for whatever reason, e.g.: nulls imports that are destined to fail in the react-native environment, adjusts paths for imports that the react-native packager's path resolution breaks on, etc. Basically a bunch of naughty special cases. A few of them may no longer be necessary as the packager has evolved some.

Feel free to ask me about what any particular part does.

@you-fail-me
Copy link
Author

you-fail-me commented Jul 11, 2017

For some reason it deletes stuff:

not reinstalling assert
not reinstalling browserify-zlib
not reinstalling inherits
not reinstalling console-browserify
not reinstalling constants-browserify
not reinstalling react-native-crypto
not reinstalling dns.js
not reinstalling domain-browser
not reinstalling events
not reinstalling https-browserify
not reinstalling os-browserify
not reinstalling path-browserify
not reinstalling process
not reinstalling punycode
not reinstalling querystring-es3
not reinstalling react-native-level-fs
not reinstalling react-native-udp
not reinstalling stream-browserify
not reinstalling string_decoder
not reinstalling timers-browserify
not reinstalling tty-browserify
not reinstalling url
not reinstalling util
not reinstalling vm-browserify
not reinstalling readable-stream
not reinstalling react-native-randombytes
installing from npm buffer
installing from github react-native-http
installing from npm react-native-tcp
installing: npm install --save buffer@^3.0.3 tradle/react-native-http#834492d react-native-tcp@^2.0.4
npm WARN gentlyRm not removing /Users/user/app/node_modules/.bin/semver as it wasn't installed by /Users/user/app/node_modules/semver
npm WARN gentlyRm not removing /Users/user/app/node_modules/.bin/json5 as it wasn't installed by /Users/user/app/node_modules/json5
+ react-native-tcp@2.0.4
+ buffer@3.6.0
+ react-native-http@1.0.0
added 1 package, removed 899 packages and updated 11 packages in 22.882s

@mvayngrib I thought it shouldn't remove anything, but it removes 899(!) packages... why would it?

@mvayngrib
Copy link
Member

oh, interesting! Those last lines are output from npm install. I'm not sure why it's removing packages, maybe it's something particular to your setup? Can you go into node_modules/.bin/rn-nodeify, look for proc.execSync(installLine,, comment out that block, re-install and re-run rn-nodeify and then see if there are any clues in the package.json's in the tree that would make npm install remove stuff?

@mvayngrib
Copy link
Member

another thought: maybe it's hitting the maximum number of open files on your system and ends up corrupting the package.json files in the tree. If that's the case, we'll need to batchify some of the operations

@mvayngrib
Copy link
Member

@you-fail-me i also see a bunch of issues on npm, like this one: infinitered/ignite#1101 Are you using npm version 5?

@you-fail-me
Copy link
Author

@mvayngrib thanks for pointing me to npm. I'm using yarn but have npm 5 installed, and turns out rn-nodeify was using it. downgrading to npm 4 seems to solve this, at least my packages no longer get removed. Thanks a lot and sorry for the issue, actually related to npm, but not to rn-nodeify

@mvayngrib
Copy link
Member

@you-fail-me no worries, it's good for me to be aware of the npm issue anyway :)

@bintoll
Copy link

bintoll commented Jul 13, 2017

+1 have the same with npm 5

@faxioman
Copy link

+1 npm 5.3.0

@aaroncraig10e
Copy link

I see this behavior, as well, with npm 5.3.0

Specifically, after
"postinstall": "rn-nodeify --install crypto,fs,http --hack"

I get an empty node_modules/react-native folder.

"postinstall": "rn-nodeify --install crypto,fs --hack"
does not remove the contents of react-native.

@jd20 jd20 mentioned this issue Sep 9, 2017
@mvayngrib
Copy link
Member

closing as it seems to be an npm issue, will re-open if proved otherwise

@pcowgill
Copy link

@mvayngrib Now that npm is at version 6.13, telling users to choose npm 3 or yarn in order to use rn-nodeify probably is out-of-date advice, right? Would it be worth removing that from the README?

@LeHoang88
Copy link

After running ./node_modules/.bin/rn-nodeify --install --hack it does some weird thing to my react-native dep (turns the folder under node_modules into a bunch of empty folders):
screen shot 2017-07-05 at 10 41 45 am
I thought it was something with yarn, but no, if I don't run rn-nodeify it's ok. Why? How can I fix?

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

No branches or pull requests

7 participants