Skip to content

Instantly share code, notes, and snippets.

@jkrems
Created May 11, 2016 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkrems/af904c355157c1d6a1109d09ac39bfc7 to your computer and use it in GitHub Desktop.
Save jkrems/af904c355157c1d6a1109d09ac39bfc7 to your computer and use it in GitHub Desktop.
Local react-native

Installing project specific tools like react-native globally is yucky. Even when it's just thin CLI wrappers. Unfortunately react-native actively breaks local npm binaries by forcing a broken bin stub into each project. So if you added ./node_modules/.bin to your $PATH, every attempt of running react-native inside of a project will fail with an annoying (and wrong) claim that you installed react-native globally.

The easiest solution I found so far:

  • npm install --save react-native-cli in your React Native project
  • Add the following post-install script: "postinstall": "npm link react-native-cli"

That will install the CLI tool locally (no more global path pollution ✨) and ensures that the broken bin stub that ships with react-native will be overridden with a working one after running npm install.

@jkrems
Copy link
Author

jkrems commented May 11, 2016

This will soon become obsolete: facebook/react-native@8295d27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment