Skip to content
forked from tradle/rn-nodeify

hack to allow react-native projects to use node core modules, and npm modules that use them

License

Notifications You must be signed in to change notification settings

leoz/rn-nodeify

 
 

Repository files navigation

rn-nodeify

Run after npm install and you can use node core modules and npm modules that use them in your React Native app.

Usage

rn-nodeify <options>

Options

--install     install node core shims (default: install all), fix the "browser" 
              (later "react-native") fields in the package.json's of dependencies
--hack        hack individual packages that are known to make the React Native packager choke

Examples

# install all shims and run package-specific hacks
rn-nodeify --install --hack
# install specific shims
rn-nodeify --install "fs,dgram,process,path,console"
# install specific shims and hack
rn-nodeify --install "fs,dgram,process,path,console" --hack

It is recommended to add this command to the "postinstall" script in your project's package.json

"scripts": {
  "start": "node node_modules/react-native/local-cli/cli.js start",
  "postinstall": "rn-nodeify --install fs,dgram,process,path,console --hack"
}

Please note...

  • rn-nodeify won't work with modules that are added using npm link.
  • modules that contain a .babelrc will cause problems with the latest react-native version (0.20 at this time), remove them after installation (rm node_modules/*/.babelrc)
  • when installing a package from git, the postinstall hook isn't triggered, run it manually instead (npm run postinstall)
  • restart the react-native packager after installing a module!
  • removing the packager cache helps as well sometimes (rm -fr $TMPDIR/react-*)

Also, see this example React Native app

About

hack to allow react-native projects to use node core modules, and npm modules that use them

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%