在全局安装时,react-native 似乎有一个错误。我需要它正确执行而不会看到此错误:
$ 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
其他论坛上发布的解决方案对我不起作用,我不明白为什么这不起作用。
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 <brentvatne@gmail.com> (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": "git@github.com:brentvatne/react-native-svgkit.git"
},
"scripts": {
"start": "node /usr/local/lib/node_modules/react-native/local-cli/cli.js start"
}
}
最佳答案
在 package.json 中使用它
"scripts": {
"android": "node node_modules/react-native/local-cli/cli.js run-android"
}
代替
"scripts": {
"android": "react-native run-android"
}
关于node.js - React-native:看起来你在全局安装了 react-native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37949641/