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
.
This will soon become obsolete: facebook/react-native@8295d27