今天是腫麼了......一上班建立React Native項目,react-native run-ios運行就報錯,運行不了...嗚嗚......node
一開始覺得本身react-native run-ios命令敲錯,再而後覺得Xcode緩存,再而後覺得電腦問題,關機重啓...問題依然存在,好在解決了....react
報錯截圖:ios
上網查了不少資料沒有找到解決方案,估計是react-native版本的問題。npm
查看package.json文件:json
發現是0.45.0版本...我記得以前都是0.44的版本的......react-native
解決方法:緩存
修改package.json的react的版本:babel
注意:react版本要和react-native版本搭配,上面版本只換一個也會出錯
{ "name": "CustomViewRNProject", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest" }, "dependencies": { "react": "16.0.0-alpha.6", "react-native": "0.44" }, "devDependencies": { "babel-jest": "20.0.3", "babel-preset-react-native": "2.0.0", "jest": "20.0.4", "react-test-renderer": "16.0.0-alpha.12" }, "jest": { "preset": "react-native" } }
具體操做:刪除node-modules文件夾,修改pakage.json文件,而後執行npm install便可.......嗚嗚...今天但是週五啊,一上午就被他坑了....spa
不過...爲何呢?爲何0.45.1的就運行報錯呢?知道的大神,留言告訴我哈...code