-bash:未找到react-native命令

时间:2019-05-05 09:32:01

标签: bash react-native terminal

我正在尝试运行一个新的react native项目,但一遍又一遍地遇到相同的问题:
-bash: react-native: command not found

我试图通过类似这样的其他帖子来解决问题:react-native: command not found 但是我仍然遇到相同的错误。

我遵循了React Native页面(https://facebook.github.io/react-native/docs/getting-started)提供的所有步骤,最后得到了以下信息:

1 npm  -version         6.4.1
2 brew -version         Homebrew 2.1.1
3 brew info watchman    stable 4.9.0 
4 brew info node        stable 12.1.0
5 echo $PATH:

/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/(myname)/Library/Android/sdk/emulator:/Users/(myname)/Library/Android/sdk/tools:/Users/(myname)/Library/Android/sdk/tools/bin:/Users/(myname)/Library/Android/sdk/platform-tools:/Users/(myname)/Library/Android/sdk/tools/bin

如果我输入:npm install -g react-native-cli

我得到:

  

/ Users /(myname)/。npm-global / bin / react-native-> /Users/(myname)/.npm-global/lib/node_modules/react-native-cli/index.js
  + react-native-cli@2.0.1
  在3.653s中更新了1个程序包

1 个答案:

答案 0 :(得分:0)

command not found的确切含义是-您尝试执行的命令(react-native)在PATH变量中列出的任何目录中都找不到。

弄清楚react-native的安装位置,并使用可执行文件的完整路径对其进行调用,或将目录添加到PATH。

基于您的问题:

5 echo $PATH:
/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/(myname)/Library/Android/sdk/emulator:/Users/(myname)/Library/Android/sdk/tools:/Users/(myname)/Library/Android/sdk/tools/bin:/Users/(myname)/Library/Android/sdk/platform-tools:/Users/(myname)/Library/Android/sdk/tools/bin

我的最佳猜测是,在安装过程中,您遵循的指示是将(myname)放在某个地方,而您实际上输入了字符串(myname),而不是输入实际的登录名。