常見報錯: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",
{
"presets": [
"react-native"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }]
],
"env": {
"production": {
"plugins": [
"transform-remove-console"
]
}
}
}
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
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
Client called nw_connection_get_connected_socket on unconnected nw_connection
解決辦法:Edit Scheme => Run => Environment Variables => Add OS_ACTIVITY_MODE:disable in the XCode。
npm ERR! missing script: start
解決辦法:在package.json文件中增加"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
}判哥。
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>
來殺死該程序。
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)贱傀。