【问题标题】:-bash: npm: command not found error message when installing React Native CLI on Mac-bash: npm: 在 Mac 上安装 React Native CLI 时找不到命令错误消息
【发布时间】:2017-11-02 00:26:32
【问题描述】:

我正在遵循 2017 年 5 月 31 日关于在 https://facebook.github.io/react-native/docs/getting-started.html#content 上安装 React Native 的最新说明。 我正在尝试安装 react-native。我成功安装了 Homebrew、Node、Watchman,但是当我尝试使用以下命令安装 React Native CLI 时:

npm install -g react-native-cli

它给了我这个错误信息:

-bash: npm: command not found

然后我使用了这个命令: curl -0 -L https://npmjs.org/install.sh | sudo sh

终端机给了我这样的信息: enter image description here

然后我尝试运行这段代码:

react-native init AwesomeProject

但收到此错误消息:

-bash: react-native: command not found

有人可以帮助我克服这个障碍,以便我可以成功安装 React Native CLI 吗?谢谢。

我已经检查了以下但无济于事:

Error when installed react-native-cli command not found

Path error while installing react-native (Command not found error)

-bash: react-native: command not found

** 注意 ** node -v 给我 v6.10.1 但是当我这样做时: npm -v 上面写着-bash: npm: command not found

我以为 npm 是带有 node.js 的。有没有可能我没有npm但有可以有nodejs?

【问题讨论】:

标签: react-native


【解决方案1】:

再次运行npm install -g react-native-cli。您之前没有安装 npm,当您运行 curl 语句时,安装了 npm,但您现在需要安装 react-native-cli。

【讨论】:

  • 尝试关闭控制台并重新打开它,然后运行 ​​npm -v 以查看您是否有 npm。如果它没有返回错误,请运行您的sudo nm install -g react-native-cli。如果这没有错误,请运行您的 react-native init AwesomeProject
  • 这很奇怪。我有节点 v6.10.1。但是当我检查 npm -v 时,它会显示-bash: npm: command not found。我以为 npm 是 NodeJs 自带的。 @Greg Billetdeaux
  • 看起来它没有正确连接到您的 PATH 变量?确保你正确安装了节点,也许再试一次。
猜你喜欢
  • 2015-06-28
  • 2019-09-04
  • 2021-02-26
  • 2019-12-20
  • 2019-05-29
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 2016-12-09
相关资源
最近更新 更多