There appears to be a bug with react-native, when it is installed globally. I need it to execute properly without seeing this error:
$ react-native run-ios
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli
Solutions posted on other forums didn't work for me, I don't see reason why this doesn't work.
package.json
:
{
"name": "react-native-svgkit",
"version": "0.2.2",
"main": "Svg.js",
"description": "A <Svg /> element for react-native that renders Svg images using SVGKit",
"author": "Brent Vatne <[email protected]> (https://github.com/brentvatne)",
"peerDependencies": {
"react": "15.1.0",
"react-native": ">=0.4.4"
},
"devDependencies": {
"react-native": ">=0.4.4",
"react-native-cli": "^0.1.10"
},
"dependencies": {
"d3": "^3.5.5",
"jsdom-jscore": "^0.1.0",
"react-native-svg": "^2.2.0"
},
"repository": {
"type": "git",
"url": "[email protected]:brentvatne/react-native-svgkit.git"
},
"scripts": {
"start": "node /usr/local/lib/node_modules/react-native/local-cli/cli.js start"
}
}
To remove react native cli globally, just use the npm uninstall -g react-native-cli command in your cmd or terminal it will uninstall react native cli from your computer.
Use this in package.json
"scripts": {
"android": "node node_modules/react-native/local-cli/cli.js run-android"
}
instead of
"scripts": {
"android": "react-native run-android"
}
In my case this problem was because because npm was installed using homebrew. A description of this problem and how to fix it can be found at on this gist. In summary the required fix is to uninstall all your npm globably installed packages, uninstall node, then reinstall node, and reinstall npm without brew.
npm list -g --depth=0 # to list all your globally installed packages
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
and then, you have to reinstall all your npm packages that were installed globally using npm install -g <package_name>
.
Unfortunately, when I rebooted my machine, the same problem re-occured. My current work around is to follow the suggestion here i.e
npm install --save-dev react-native-cli
Any explanation as to what is going on is welcome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With