react-native:找不到命令

时间:2016-11-12 03:40:33

标签: linux bash reactjs npm react-native

我是React原生的新手,按照“getting started”页面上的说明,我遇到了以下问题。我运行了npm install,但是得到react-native: command not found。我做了brew install nodebrew install watchman并且安装都没有错误。另外我今天早些时候从mac app store下载了xcode。任何帮助表示赞赏!

此外 - 我尝试了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
└── react-native-cli@1.2.0 

 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上的npm文档将npm的默认目录更改为另一个目录

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 个答案:

答案 0 :(得分:2)

从评论中删除:

根据指示将~/.npm-global/bin添加到您的路径:

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

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