React-Native開發過程中遇到的一些報錯以及一些常用命令
1、升級node(對安裝包安裝或者低版本的如6.11.4不生效)
1>檢視node版本,沒安裝的請先安裝;
$ node -v
2>清除node快取;
$ sudo npm cache clean -f
3>安裝node版本管理工具'n';
$ sudo npm install n -g
4>使用版本管理工具安裝指定node或者升級到最新node版本;
$ sudo n stable (安裝node最新版本)
$ sudo n 8.9.4 (安裝node指定版本8.9.4)
5>使用node -v檢視node版本,如果版本號改變為你想要的則升級成功。
2、對於未知安裝的node,解除安裝刪除重新安裝
which node
/usr/local/bin/node
可以找到對應的資料夾,可直接刪除
3、執行brew install node後,報錯:
node-7.6.0 already installed, it's just not linked
執行
// 給當前使用者新增目錄許可權
sudo chown -R $(whoami) /usr/local
brew link --overwrite node
brew postinstall node
4、執行npm i報錯:
npm ERR! fatal: unable to access 'https://
這段指令碼執行區git拉取程式碼所用到(預設用ssh)的埠被禁止使用.應該改用https的方式進行下載.
執行命令:
git config --global url."https://".insteadOf git://
再執行 npm i可能還會報錯如下:
npm ERR! fatal: unable to access 'https://[email protected]/react-native-community/react-native-camera.git/': LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
設定正確的代理ip:
區域性代理:
git config --global https.proxy https://127.0.0.1:1080
git config --global http.proxy http://127.0.0.1:1087
全域性設定代理:
export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;
再執行npm 可能出現報錯:
WARN registry Using stale package data from https://registry.npm.taobao.org/ due to a request error during revalidation.
執行:
rm ./package-lock.json
rm -r ./node_modules
npm cache clear —force
再執行npm 可能出現報錯:
執行:
npm install -g npm
對於終端出現的警告:
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
執行:
npm install -save [email protected]~16.4.1
執行:npm i
拉取jsbundle:
react-native bundle --entry-file index.js --bundle-output ./ios/index.bundle --platform ios --assets-dest ./ios --dev false
如果出現報錯:
Cannot read property 'bindings' of null
// babel-preset-react-native版本過低造成,React Native 0.56.0 需要 [email protected] 版本
執行:
npm remove babel-preset-react-native
npm install --save [email protected]
需要刪除並重新安裝:
執行:
rm -rf node_modules && npm install
因為當前的專案需要相容之前的老版本,替換以下路徑的資料夾:
iloop_boss/node_modules/react-native-camera/ios
iloop_boss/node_modules/react-native/Libraries/Renderer/shims
替換完成後刪除takeSnapshot.js、TouchHistoryMath.js檔案
開啟專案工程,執行成功報錯:
React Native version mismatch.
JavaScript version: 0.56.0
Native version: 0.54.2
Make sure that you have rebuilt the native code. If the problem persists try clearing the Watchman and packager caches with `watchman watch-del-all && react-native start --reset-cache`.
執行:
npm install --save [email protected]
react-native upgrade
解決!
5、編譯執行報錯:
Module AppRegistry is not a registered callable module
不知道是什麼問題,在模擬器會報錯,在真機上可以正常執行,重新npm , 清除快取一直到最後重啟電腦才解決
報錯持續更新。。。。