最近使用react-native init 'XXX' ,报 500 。
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 Metro Bundler cache: `rm -rf $TMPDIR/react-*` or `npm start -- --reset-cache`. 4. Remove haste cache: `rm -rf $TMPDIR/haste-map-react-native-packager-*`.
上述几种方法都试了还是不行,它好像是一个与依赖相关的0.56错误。“解决方案”是找到依赖关系版本的正确组合。通过安装这些版本找到了解决办法:
react-native >> 0.55.4
babel-core >> latest
babel-loader >> latest
babel-preset-react-native >> 4.0.0
所以也可以执行下面命令:
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
npm uninstall react-native
npm install --save react-native@0.55.4
react-native run-android
npm install --save babel-core@latest babel-loader@latest
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@4.0.0
react-native run-android