2016-11-12 198 views
0

我是React native的新手,並按照'getting started'頁面上的說明操作,遇到以下問題。我跑了npm安裝,但是我得到react-native: command not found。我做了brew install nodebrew install watchman,並且都安裝了沒有錯誤。此外,我今天早些時候從mac應用商店下載了xcode。任何幫助表示讚賞!react-native:找不到命令

此外 - 我試過這個SO post的解決方案,但是,它仍然無法正常工作。

下面是從終端輸出,以及我的.bashrc文件位於〜/。

Desktop npm install -g react-native-cli 
/Users/roni/.npm-global/bin/react-native -> /Users/roni/.npm-global/lib/node_modules/react-native-cli/index.js 
/Users/roni/.npm-global/lib 
└── [email protected] 

Desktop react-native init reactNativeTest 
-bash: react-native: command not found 

的.bashrc

source /usr/local/opt/nvm/nvm.sh 
export PATH="/usr/local/share/npm/bin:$PATH" 

### Added by the Bluemix CLI 
source /usr/local/Bluemix/bx/bash_autocomplete 

請注意,我改變故宮的默認目錄到另一個目錄,每故宮文檔上fixing npm permissions

Make a directory for global installations: 

mkdir ~/.npm-global 
Configure npm to use the new directory path: 

npm config set prefix '~/.npm-global' 
Open or create a ~/.profile file and add this line: 

export PATH=~/.npm-global/bin:$PATH 
Back on the command line, update your system variables: 

source ~/.profile 
+1

你加'〜/ .npm全局/ bin'到PATH? 'echo $ PATH'的輸出是什麼? – DTing

+0

@Ding是的,就是這樣!我將〜/ .npm-global/bin添加到了我的.bash_profile文件中,它可以工作。如果您回覆答案,我會將其標記爲正確。乾杯。 –

回答

1

從註釋抄了下來:

添加~/.npm-global/bin到PATH,按方向:

npm config set prefix '~/.npm-global' 
Open or create a ~/.profile file and add this line: 

export PATH=~/.npm-global/bin:$PATH