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 進行測試!完成!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM