React Native常見報錯

常見報錯:Error:Cannot find module 'jest-haste-map'

Error: Cannot find module 'jest-haste-map'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

解決辦法:npm install jest-haste-map --save

npm install jest-haste-map --save
npm WARN @babel/plugin-check-constants@7.0.0-beta.38 requires a peer of @babel/core@7.0.0-beta.38 but none is installed. You must install peer dependencies yourself.

+ jest-haste-map@23.4.1
added 4 packages and updated 1 package in 19.344s

Property right of AssignmentExpression expected node to be of a type ["Expression"] but instead got null

解決辦法:修改package.json文件devDependencies增加,修改.babelrc文件

    "@babel/plugin-proposal-decorators": "7.0.0-beta.47",
    "babel-preset-react-native": "5.0.1",
WechatIMG816.jpeg
{
  "presets": [
    "react-native"
  ],
  "plugins": [
   ["@babel/plugin-proposal-decorators", { "legacy": true }]
  ],
  "env": {
    "production": {
      "plugins": [
        "transform-remove-console"
      ]
    }
  }
}

WX20180806-224032@2x.png

Cannot read property...

node_modules/react-native/Libraries/react-native/react-native-
implementation.js: Cannot read property 'bindings' of null (null))

解決辦法:npm i babel-preset-react-native@5

Bundling index.ios.js 99.0% (405/407), failed.

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.

解決辦法:

watchman watch-del-all
rm -rf node_modules && npm install
npm start --reset-cache

react-native.js: Unable to find this module in its module map or any of the node_modules directories

解決辦法:

npm i --save react@15.0.2

Bundling failed: Error: Unable to resolve module react-native-tab-view

解決辦法:

npm i github:react-navigation/react-native-tab-view

You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux

解決辦法:在RN代碼里面全局查找process.env.NODE_ENV將其值設(shè)為production,可能其值現(xiàn)在為development。

const global_def = `(function (global) {global.__DEV__=false;global.__BUNDLE_START_TIME__=this.nativePerformanceNow?nativePerformanceNow():Date.now();global.process=this.process||{};global.process.env=process.env||{};global.process.env.NODE_ENV='production';})(this);`

[React-native: Super expression must either be null or a function, not undefined]

解決辦法:修改引入Component方式重虑。

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight,
} from 'react-native';
[React native: Cannot add a child that doesn't have a YogaNode or parent node(Trying to add a 'ReactRawTextShadowNode' to a 'LayoutShadowNode')]
      <View style={[styles.container]}>
      <BoxShadow setting={shadowOpt}>
                <TouchableOpacity style={{
                    position:"relative",
                    width: 160,
                    height: 170,
                    backgroundColor: "#fff",
                    borderRadius:3,
                    // marginVertical:5,
                    overflow:"hidden"}}>
                    測試
                </TouchableOpacity>
            </BoxShadow>
      </View>

解決辦法:刪除組件里面的含有"http://"注釋,刪除//marginVertical:5這一行,還是報錯节仿,后來發(fā)現(xiàn)TouchableOpacity里面不能直接添加漢字,需要加Text颖榜。

   <BoxShadow setting={shadowOpt}>
                <TouchableOpacity style={{
                    position:"relative",
                    width: 160,
                    height: 170,
                    backgroundColor: "#fff",
                    borderRadius:3,
                    overflow:"hidden"}}>
                    <Text>測試</Text>
                </TouchableOpacity>
            </BoxShadow>

   <BoxShadow setting={shadowOpt}>
                <TouchableOpacity style={{
                    position:"relative",
                    width: 160,
                    height: 170,
                    backgroundColor: "#fff",
                    borderRadius:3,
                    overflow:"hidden"}}>
                    {!!'測試'}
                </TouchableOpacity>
            </BoxShadow>

后面這一種測試二字顯示不出來惭适,為了防止崩潰,加兩個J鑫!將"測試"取兩次反锣笨,轉(zhuǎn)化為BOOL防止為空蝌矛。

/react-native/third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: 'config.h' file not found #include "config.h" // to figure out pthreads support

解決辦法:

Close Xcode.
cd <Project-Folder>/node_modules/react-native/third-party/glog-0.3.4
Run ./configure
Run make
Run make install
Open Xcode and try building the Project.
undefined is not an object (evaluating ‘RNGestureHandlerModule.state’)

解決辦法:

remove node_modules and package-lock.json
npm install
npm install --save react-navigation
npm install --save react-native-gesture-handler
react-native link
官方給出解決方案
yarn add react-navigation
# or with npm
# npm install --save react-navigation
yarn add react-native-gesture-handler
# or with npm
# npm install --save react-native-gesture-handler
react-native link react-native-gesture-handler
06B65DD6-45DD-4699-89DB-62FA93BE2D31.png
Cannot read property 'changedBits' of undefined

解決辦法:升級react-native版本,"react-native": "0.55.3"错英,npm install入撒。

error: bundling failed: Error: Unable to resolve module metro/src/lib/bundle-modules/HMRClient from /Users/<user-directory>/Desktop/temp/react-native/Libraries/Utilities/HMRClient.js: Module does not exist in the module map

解決辦法:升級react-native版本,"react-native": "0.55.4",npm install椭岩。

unsupported top level event type "onGestureHandlerStateChange" dispatched

解決辦法:降低"react-native-gesture-handler":"1.0.14",npm install茅逮。

Build input file cannot be found: 'node_modules/react-native/third-party/double-conversion-1.1.6/src/fixed-dtoa.cc'

解決辦法:

$ cd node_modules/react-native/scripts && ./ios-install-third-party.sh && cd ../../../
$ cd node_modules/react-native/third-party/glog-0.3.5/ && ../../scripts/ios-configure-glog.sh && cd ../../../../
undefined is not an object (evaluating 'rngesturehandlermodule2.default.Direction')

解決辦法:

Right Click Libraries "Add Files to Project"
/node_modules/react-native-gesture-handlers/ios/RNGestureHandler.xcodeproj
Go to build phases and add libRNGestureHandler.a
Run
1.gif
Client called nw_connection_get_connected_socket on unconnected nw_connection

解決辦法:Edit Scheme => Run => Environment Variables => Add OS_ACTIVITY_MODE:disable in the XCode。

8.gif
npm ERR! missing script: start

解決辦法:在package.json文件中增加"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
}判哥。


QQ20190702-210019@2x.png
Connection to localhost port 8081 [tcp/sunproxyadmin] succeeded!

Port 8081 already in use, packager is either not running or not running correctly
Command PhaseScriptExecution failed with a nonzero exit code
解決辦法:RN使用8081端口作為資源加載的端口献雅,如果端口被占用,就會產(chǎn)生該編譯錯誤塌计,就算成功運行挺身,APP也無法加載Bundler,導(dǎo)致紅色告警頁面锌仅。

sudo lsof -i:8081

查看占用該端口的應(yīng)用章钾,并找到其PID墙贱,利用命令

sudo kill <pid>

來殺死該程序。


QQ20190702-212821@2x.png
Build input file cannot be found: '/Users/cloud/Documents/RNDemo/LearnReduxProject/node_modules/react-native/Libraries/WebSocket/libfishhook.a'

解決辦法:Try to switch back to the Legacy Build System (File > Project Settings > Workspace Settings > Legacy Build System)贱傀。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末嫩痰,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子窍箍,更是在濱河造成了極大的恐慌,老刑警劉巖丽旅,帶你破解...
    沈念sama閱讀 218,546評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件椰棘,死亡現(xiàn)場離奇詭異,居然都是意外死亡榄笙,警方通過查閱死者的電腦和手機(jī)邪狞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,224評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來茅撞,“玉大人帆卓,你說我怎么就攤上這事∶浊穑” “怎么了剑令?”我有些...
    開封第一講書人閱讀 164,911評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長拄查。 經(jīng)常有香客問我吁津,道長,這世上最難降的妖魔是什么堕扶? 我笑而不...
    開封第一講書人閱讀 58,737評論 1 294
  • 正文 為了忘掉前任碍脏,我火速辦了婚禮,結(jié)果婚禮上稍算,老公的妹妹穿的比我還像新娘典尾。我一直安慰自己,他們只是感情好糊探,可當(dāng)我...
    茶點故事閱讀 67,753評論 6 392
  • 文/花漫 我一把揭開白布钾埂。 她就那樣靜靜地躺著,像睡著了一般科平。 火紅的嫁衣襯著肌膚如雪勃教。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,598評論 1 305
  • 那天匠抗,我揣著相機(jī)與錄音故源,去河邊找鬼。 笑死汞贸,一個胖子當(dāng)著我的面吹牛绳军,可吹牛的內(nèi)容都是我干的印机。 我是一名探鬼主播,決...
    沈念sama閱讀 40,338評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼门驾,長吁一口氣:“原來是場噩夢啊……” “哼射赛!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起奶是,我...
    開封第一講書人閱讀 39,249評論 0 276
  • 序言:老撾萬榮一對情侶失蹤楣责,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后聂沙,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體秆麸,經(jīng)...
    沈念sama閱讀 45,696評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,888評論 3 336
  • 正文 我和宋清朗相戀三年及汉,在試婚紗的時候發(fā)現(xiàn)自己被綠了沮趣。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,013評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡坷随,死狀恐怖房铭,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情温眉,我是刑警寧澤缸匪,帶...
    沈念sama閱讀 35,731評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站类溢,受9級特大地震影響豪嗽,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜豌骏,卻給世界環(huán)境...
    茶點故事閱讀 41,348評論 3 330
  • 文/蒙蒙 一龟梦、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧窃躲,春花似錦计贰、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,929評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至洒琢,卻和暖如春秧秉,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背衰抑。 一陣腳步聲響...
    開封第一講書人閱讀 33,048評論 1 270
  • 我被黑心中介騙來泰國打工蛤织, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留夭拌,地道東北人台汇。 一個月前我還...
    沈念sama閱讀 48,203評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像啦撮,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子汪厨,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,960評論 2 355

推薦閱讀更多精彩內(nèi)容