2017-06-01 130 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 –