我正在获得-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 └── react-native-cli@0.2.0
从上面的输出可以清楚地看到路径:/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
而已!!!