React native 配置安裝請參考這里.
前面比較順利潘飘,當(dāng)運行到這里的時候出現(xiàn)問題尽棕;
$ npm install -g react-native-cli
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
npm ERR! /Users/luke/react-native/npm-debug.log
出現(xiàn)這個問題通常是因為registry配置有問題瑟慈,這個可以在~/.npmrc里看到。可以通過以下三種方法解決:
- 刪除npmrc文件下翎,重新創(chuàng)建
$vi ~/.npmrc
registry = http://registry.cnpmjs.org
- 使用npm config命令配置
$ npm config set registry http://registry.cnpmjs.org
$npm info underscore
- 和方法2類似
npm --registry http://registry.cnpmjs.org info underscore
以上方法均可解決npm install 的網(wǎng)絡(luò)問題混稽。