ReactNative 在 Visual Studio Code環(huán)境下報(bào)錯(cuò)
-
error: bundling failed: TypeError: Cannot read property 'bindings' of null
原因:package.json 中的"babel-preset-react-native” 版本過低,修改到”5.0.0"及以上
解決方案:
"babel-preset-react-native": "^5.0.0” -
error: bundling failed: Error: Unable to resolve module
react-native-root-toast
from/Users/weskhen/Documents/mst/RNDemo/app/components/Toast.js
: Modulereact-native-root-toast
does not exist in the Haste module map1.對應(yīng)的moudle 確實(shí)不存在,需要手動添加
2.查看moudle存在,訪問路徑錯(cuò)誤
-
Error while executing command 'react-native run-ios --simulator iPhone X --no-packager’
ios目錄下,沒有xcode的工程文件
//工程編譯報(bào)錯(cuò)
TypeError: Cannot read property '2' of null
-
Module AppRegistry is not a registered callable module (calling runApplication)
do npm run start --reset-cache or react-native start --reset-cache 1. Clear watchman watches: `watchman watch-del-all`. 2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`. 3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
-
error Invalid tag name "^23?.4.1": Tags may not have any characters that encodeURIComponent encodes.
package.json文件出現(xiàn)錯(cuò)誤!
iOS編譯報(bào)錯(cuò)
- warning :Native component for “RCTImageView” does not exist
需要引入 RCTImage 模塊解決
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'RCTImage']
Android編譯報(bào)錯(cuò)
-
unable to load script from assets ‘index.android bundle’
第一步(創(chuàng)建缺失的目錄):mkdir android\app\src\main\assets
第二步(在創(chuàng)建好的目錄添加程序需要的文件):react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
第三步:react-native run-android
- 安卓模擬器不能聯(lián)網(wǎng)
cd到tools下
wujian-2:platform-tools weskhen./emulator -list-avds
Nexus_5X_API_27
Pixel_XL_Edited_API_27
wujian-2:tools weskhen$ cd /Users/weskhen/Documents/Android/android-sdk-macosx/emulator
emulator @Pixel_XL_Edited_API_27 -dns-server 8.8.8.8,114.114.114.114