React native 配置安装请参考这里.
前面比较顺利,当运行到这里的时候出现问题;
$ 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
出现这个问题通常是因为registry配置有问题,这个可以在~/.npmrc里看到。可以通过以下三种方法解决:
- 删除npmrc文件,重新创建
$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 的网络问题。