react-native運行ios報錯總結

來源:互聯網
上載者:User
Cannot find entry file index.ios.js [index.android.js] in any of the roots

網上一搜出現這個問題的人還挺多,解決方案就是:
項目路徑下運行:npm start -- -reset-cache
再重新啟動項目:react-native run-ios(run-android)
如果還是失敗那麼就在這裡看看有沒有解決方案 NPM modules get required from /Users/node_modules/ instead of the project directory

同樣的我還遇到了這個問題,就是node_modules裡面的所有依賴檔案目錄都變成了/users/這種形式,解決方案: 刪除 node_modules:rm -rf node_modules && npm install 清空watchman: watchman watch-del-all npm cache clean && npm install

如果還是失敗那麼就在這裡看看有沒有解決方案

如果還是解決不了,那麼我猜你是不是用了cnpm install 而不是npm install?
或者說你用的是npm install ?

這兩種安裝方式都可能會導致問題,特別是cnpm。。在這裡千萬不能用。
推薦用的方式是:yarn

給npm設定淘寶鏡像:

npm config set registry https://registry.npm.taobao.org --globalnpm config set disturl https://npm.taobao.org/dist --global

安裝yarn: npm install yarn -g

給yarn設定淘寶鏡像:

yarn config set registry https://registry.npm.taobao.org --globalyarn config set disturl https://npm.taobao.org/dist --global

重新使用命令yarn 代替npm install,然後重新啟動RN項目,應該就不會報錯了。 ReactComponentTreeHook.purgeUnmountedComponents is not a function

其實如果報了這個錯,估計你安裝依賴的時候已經看到了一句警告:react-native@0.48.4" has incorrect peer dependency "react@16.0.0-alpha.12".但是被你忽略了,解決方案就是修改你現在安裝的react版本為提示的版本:
yarn add react@16.0.0-alpha.12 No bundle URL present. Make sure you’re running a packager server or have included a .jsbundle file in your application bundle.

這個錯誤是模擬器紅屏彈出的錯誤資訊:

Xcode或者命令列提示的錯誤是:third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: ‘config.h’ file not found,搜了一下解決辦法:

刪除ios/build路徑,然後重新react-native run-ios

沒有用,接著第二種辦法:

刪除node_modules/third-party,然後重新react-native run-ios

但是我的node_modules下根本沒有這個外掛程式,所以我用了最簡單粗暴的方法:刪除整個node_modules目錄,然後重新使用yarn命令安裝,最後解決了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.