RN常见错误

456 阅读1分钟

1.编译控件报错:requireNativeComponent: "" was not found in the UIManager.

解决: juejin.cn/post/684490…

2.npm start运行报错:Invalid regular expression: /(node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class

解决:

blog.csdn.net/qq_42030756…

直接在blacklist.js文件中添加反转义字符即可

3.报错undefined is not an object (evaluating’_react2.PropTypes.bool’)

是本地的react版本配置不对,先删除本地的node_modules,然后重新加载react,注意下边的版本和项目的版本一致,不要使用npm install安装,直接运行下边的命令

解决方案:

yarn add react@16.0.0-alpha.12

yarn add react-native@0.48.0

4.Looks like you installed react-native globally, maybe you meant react-native-cli?

如果你在使用打包命令出现以下问题,前提是你安装了react-native-cli,不管是不是全局,还是dev安装的,npm install --save-dev react-native-cli或者npm install -g react-native-cli的,都不好使:

解决方案:

直接在dependencies里面依赖react-native-cli,在执行打包即可

5.react-native错误:Application has not been registered

关闭rn相关项目和webstore启动rn项目,重新启动新的项目,也就是同一时间尽量保证只有一个rn项目在跑,如果不行,关闭webstore在npm start重启项目

6.cannot read properties of undefined (reading 'bool')

这个和上边的操作方式一样

解决方案:

yarn add react@16.0.0-alpha.12

yarn add react-native@0.48.0

7.undefinded is not an object(evaluating '_react3.defalut.PropTypes.bool')

这个是本地缺少了相应的依赖包:

解决方案:

yarn add prop-types@15.6.0

8.Can't find variable:rmc

没有安装对应的组件或者变量中依赖有问题

解决方案,安装package.json中对应的版本即可:

yarn add rmc-date-picker@6.0.10