2017-06-01 128 views
0

我在关注安装React Native https://facebook.github.io/react-native/docs/getting-started.html#content的最新说明05/31/2017。 我正在尝试安装react-native。我成功安装自制软件,节点,看守员,但是当我尝试安装阵营本地CLI使用此命令:在Mac上安装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带有节点。有没有可能我没有npm,但可以有nodejs?

+0

[为什么“有人可以帮我吗?”不是一个实际的问题?](https://meta.stackoverflow.com/q/284236/62576) –

+0

可能重复[错误时安装react-native-cli命令未找到](https://stackoverflow.com/questions/29767729/error-when-installed-react-native-cli-command-not-found)和[安装react-native时出现路径错误(Command not found error)](https://stackoverflow.com/q/32253981/ 62576)和[-bash:react-native:命令未找到错误](https://stackoverflow.com/q/33282545/62576) –

+0

@KenWhite您能否向我解释这些说明:您必须确保/ usr/local/share/npm/bin在您的PATH中使用npm安装的二进制文件。 将以下内容添加到〜/ .bashrc中: export PATH =“/ usr/local/share/npm/bin:$ PATH” 然后重新加载shell会话。 这在https:// stackoverflow中找到。com/questions/33282545/bash-react-native-command-not-found文章 –

回答

0

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

+0

我得到了同样的错误信息 –

+0

尝试关闭控制台并重新打开它,然后运行'npm -v'来查看你是否有npm。如果它不返回错误,请运行'sudo nm install -g react-native-cli'。如果这没有错误,那么运行你的'react-native init AwesomeProject' –

+0

这很奇怪。我有节点v6.10.1。但是当我检查npm -v时,它会显示'-bash:npm:command not found'。我认为npm带有NodeJs。 @Greg Billetdeaux –