微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node.js – React-native:看起来你全局安装了react-native

当全局安装时,似乎存在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"
  }
}

解决方法

在我的情况下,这个问题是因为因为npm是使用自制软件安装的.可以在 this gist找到此问题的说明以及如何解决此问题.总之,所需的修复是卸载所有npm球形安装的软件包,卸载节点,然后重新安装节点,并重新安装没有brew的npm.

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

然后,您必须使用npm install -g< package_name>重新安装全局安装的所有npm软件包.

不幸的是,当我重新启动机器时,同样的问题又重新出现了.我目前的工作是遵循建议here,即

npm install --save-dev react-native-cli

有关正在发生的事情的任何解释都是受欢迎的.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐