初次使用react-native 依照官網
終端輸入:react-native init Myapp
cd Myapp
react-native run-ios
默認打開模擬器一片紅屏報錯如下:
Cannot find entry file index.ios.js in any of the roots
解決方案
刪除 node_modules:rm -rf node_modules && npm install
再react-native init Myapp重啟還是報錯如下:
解決方案
1、刪除ios/build路徑
2、開兩個終端 cd Myapp
一個輸入 npm start
一個啟動項目 react-native run-ios
於是問題解決,可以正常運行!