React-native 加载新项目的时候出错

sudo react-native init FirstApp

 使用react-native加载新的项目的时候报错了!!!!

 

npm WARN react-native@0.43.2 requires a peer of react@16.0.0-alpha.6 but none was installed.

npm WARN You are using a pre-release version of node and things may not work as expected

You are currently running Node v8.0.0-pre but React Native requires >=4. Please use a supported version of Node.

See https://facebook.github.io/react-native/docs/getting-started.html

 ┌────────────────────────────────────────────────────────────────────────────┐ 

 │  You are currently running io.js v8.0.0-pre.                               │ 

 │                                                                            │ 

 │  React Native runs on Node 4.0 or newer. There are several ways to         │ 

 │  upgrade Node.js depending on your preference.                             │ 

 │                                                                            │ 

 │  nvm:       nvm install node && nvm alias default node                     │ 

 │  Homebrew:  brew unlink iojs; brew install node                            │ 

 │  Installer: download the Mac .pkg from https://nodejs.org/                 │ 

 │                                                                            │ 

 │  About Node.js:   https://nodejs.org                                       │ 

 │  Follow along at: https://github.com/facebook/react-native/issues/2545   

 

原因是我的mac在没有安装react-native之前已经下载了一个v8.0.0.0 pre 版本的node.js。

现在看来应该node的版本和react-native的版本不兼容。

所以,我决定安装它的要求安装一个 4.0 版本以上的node.js给它。

然后我用HomeBrew的管理器下载node(HomeBrew相关使用请百度)

brew install node    

 

当它成功下载完了后,发出了以下的错误:

 

这张图的意思就是说 现在下载的node版本 软连接到 当前版本的node失败了。但是它给出了如果将下载的版本软连接到当前版本。

rm /usr/local/bin/node  // 移除当前版本的node

 

注意:如果有权限限制问题,就在命令行前面加上 sudo

sudo brew link --overwrite node
brew link --overwrite --dry-run node

 

 

然后在命令行输入:node 进行测试!完成!

 

posted on 2017-04-09 15:31  野区杰西  阅读(2753)  评论(0编辑  收藏  举报

导航