【问题标题】:Error when installed react-native-cli command not found找不到安装 react-native-cli 命令时出错
【发布时间】:2015-06-28 08:23:46
【问题描述】:

提前感谢您的帮助,我一般是 Mac 新手,所以如果它非常简单,请原谅我的问题,我安装了 native-react-cli 并想打开/创建一个项目。但我收到错误“react-native:找不到命令”

我安装 react-native-cli:

npm install -g react-native-cli
npm http GET https://registry.npmjs.org/react-native-cli
npm http 304 https://registry.npmjs.org/react-native-cli
npm WARN package.json react-native-cli@0.1.3 No README.md file found!
/usr/local/share/npm/bin/react-native -> /usr/local/share/npm/lib/node_modules/react-native-cli/index.js
react-native-cli@0.1.3 /usr/local/share/npm/lib/node_modules/react-native-cli

我尝试打开/创建一个项目:

react-native AwesomeProject
-bash: react-native: command not found
react-native init helloWorld
-bash: react-native: command not found

感谢您的宝贵时间,非常感谢您的帮助

【问题讨论】:

  • 这似乎不是 PATH 问题,因为 watchman(以前安装正确) - 查看版本但未找到 react-native 时 watchman -v 3.1.0 react-native - v -bash: react-native: 找不到命令
  • 好的,我找到了答案,对于其他人。我没有正确的 PATH 设置。在您的终端中,使用 echo $PATH 检查路径 /usr/local/share/npm/bin 是否存在于 /etc/paths 中。如果不使用 'sudo nano /etc/paths' 在 nano 中打开路径文件。将所需路径添加到文件底部,然后键入“control-x”退出并键入“Y”保存修改后的缓冲区。然后再次检查路径,这对我有用。
  • 作为临时修复,您可以在 react-native-xcode.sh 的开头添加 PATH=${PATH}:/usr/local/bin 。您可以使用npm config --global get prefix 检查您的 npm bin 目录

标签: react-native


【解决方案1】:

我遇到了这个问题,这仅仅是因为我的 brew 不是最新的。

我更新了 brew 并重新安装了https://facebook.github.io/react-native/docs/getting-started.html#content 中列出的组件,它再次感到高兴。

【讨论】:

    【解决方案2】:

    你必须为你的路径变量添加正确的路径。

    检查一下:react-native: command not found

    【讨论】:

      猜你喜欢
      • 2017-11-02
      • 2023-04-06
      • 2019-05-29
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 2019-08-02
      • 1970-01-01
      相关资源
      最近更新 更多