android – react-native:command not found

我正在获得-bash:react-native:命令在创建反应本机项目时找不到错误.

以下是附加信息

1. brew --version
   homebrew 0.9.9
2  brew info watchman
   watchman `enter code here`stable 4.50
   /usr/local/Cellar/watchman/4.4.0
3. brew info flow
   stable 0.24.1
   /usr/local/Cellar/flow/0.24.1
4. brew info node
   stable 6.1.0
   /usr/local/Cellar/node/6.1.0
5. npm -version
   3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

我尝试从下面的链接建议的步骤,但仍然我得到相同的错误.

> react-native-command-not-found

我没有在解决方案中指定的任何“npm”目录

Ashoks-MacBook-Pro:share Ashok$ls
aclocal     doc     info        ruby-build  zsh
autoconf    emacs       man     systemtap

但是我发现npm文件存在于下面的位置.

/usr/local/Cellar/node/6.1.0/etc/bash_completion.d

我卸载了反应本机并重新安装,但仍然面临同样的问题.

解决方法

添加正确的路径到PATH变量问题后解决.

以下是找到正确路径的步骤.

1. Enter: npm install -g react-native-cli
output: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native ->/usr/local/Cellar/node/6.1.0/libexec/npm/lib/node_modules/react-native-cli/index.js/usr/local/Cellar/node/6.1.0/libexec/npm/lib
└── [email protected]

从上面的输出可以清楚地看到路径:/usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native

export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"

react-native init appName

cd appName

react-native run-ios

如果你得到xcrun:错误:无法找到实用工具“simctl”在这个阶段你可以重新使用以下步骤

XCode – >首选项 – >地点 – >命令行工具 – >选择Xcode 7.2.1

您可以从xcrun unable to find simctl找到原始解决方

感谢@fbozo

而已!!!

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...