RN 采坑

Posted by PaysonChen Blog on March 21, 2021

RN 报如下错误时

1
2
3
4
5
6
7
8
9
10
11
 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 Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`. 

  4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.

有可能因为 RN与react版本不匹配

在执行

1
2
3
yarn add react-native

查看warning

1
2
3
4
5
warning "react-native > use-subscription@1.5.0" has unmet peer dependency "react@^17.0.0".

warning " > react-native@0.63.3" has unmet peer dependency "react@16.13.1".

需要添加react依赖版本