react-native:找不到命令 [英] react-native: command not found
问题描述
创建react-native项目时,我收到 -bash:react-native:command not found error 。
I am getting -bash: react-native: command not found error while creating react-native project.
以下是其他信息
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
我尝试了从以下链接建议的步骤,但我仍然得到同样的错误。
I tried suggested steps from the below link but still i am getting same error.
- react-native-command-not-found
我没有他们在解决方案中指定的任何npm目录
I don't have any "npm" directory which they have specified in the solution
Ashoks-MacBook-Pro:share Ashok$ ls
aclocal doc info ruby-build zsh
autoconf emacs man systemtap
但我发现npm文件存在于以下位置。
But i found npm file exist in below location.
/usr/local/Cellar/node/6.1.0/etc/bash_completion.d
我卸载了react-native并再次安装,但我仍面临同样的问题。
I uninstalled react-native and installed again but still i am facing same issue.
推荐答案
在向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
from above output you can clearly see the path: /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,您可以使用以下步骤重新开始
if you getting xcrun: error: unable to find utility "simctl" at this stage you can reslove using below steps
XCode - >首选项 - >位置 - >命令行工具 - >选择Xcode 7.2.1
您可以从 xcrun无法找到simctl
感谢@fbozo
就是这样!!!
这篇关于react-native:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!