sudo react-native init FirstApp
使用react-native加载新的项目的时候报错了!!!!
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Andale Mono"; color: #29f914; background-color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Andale Mono"; color: #c33720; background-color: #000000 }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px "Andale Mono"; color: #34bd26; background-color: #000000 }
span.s1 { color: #bfbfbf }
span.s2 { }
span.s3 { color: #000000; background-color: #999900 }
span.s4 { color: #29f914 }
span.s5 { color: #34bd26 }
npm WARN [email protected] requires a peer of [email protected] 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 进行测试!完成!