文章目录

##1.打开终端输入:git clone https://github.com/facebook/react-native.git下载完成后,在
QQ20160919-0.png目录中存在下载后的相关文件。

##2.终端输入:cd react-native && npm install
出现提示,npm command no found 因为你的mac中 npm没有安装

###npm是什么?

  • NPM的全称是Node Package Manager ,是一个NodeJS包管理和分发工具,已经成为了非官方的发布Node模块(包)的标准
  • ###如何安装npm呢?
    一:如果你安装了Homebrew
    如何安装Homebrew见这里:http://brew.sh/index_zh-cn.html

    直接使用命令:

    brew install node
    

    二:直接从官网上下载安装
    点击进入网址,https://nodejs.org/en/#download
    QQ20160919-1.png
    点击下载“Current”,下载完成后执行*.pkg安装完成即可。
    安装完成后,就可以运行React-Native Examples下的demo了。
    ps:如果通过终端命令下载不成功或是下载50%重新下载的导致下载的下载两次的如下图所示:
    QQ20160919-2.png

    则需要删除目录中的react-native,否则运行demo时会出现如下错误

    Failed to build DependencyGraph: @providesModule naming collision:
     Duplicate module name: AppEventsTest
     Paths: /Users/Founder/react-native/react-native/IntegrationTests/AppEventsTest.js collides with /Users/Founder/react-native/IntegrationTests/AppEventsTest.js
     This error is caused by a @providesModule declaration with the same name across two different files.
     Error: @providesModule naming collision:
     Duplicate module name: AppEventsTest
     Paths: /Users/Founder/react-native/react-native/IntegrationTests/AppEventsTest.js collides with /Users/Founder/react-native/IntegrationTests/AppEventsTest.js
     This error is caused by a @providesModule declaration with the same name across two different files.
    at HasteMap._updateHasteMap (/Users/Founder/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:155:13)
    at module.getName.then.name (/Users/Founder/react-native/packager/react-packager/src/node-haste/DependencyGraph/HasteMap.js:115:31)
    Process terminated. Press <enter> to close the window
    

    如上述步骤,React-Native的demo就可以运行起来了。
    参考文档:facebook_github

    文章目录
    Fork me on GitHub