当我尝试制作hello-world
样本时出现此错误:
react-native init hello_world
cd hello_world
react-native run-android
即使我跑了:
npm install -g react-native-git-upgrade
react-native-git-upgrade
我在commend line console
上遇到了同样的错误。
我搜索并尝试了很多解决方案,但它似乎不起作用:
例如:
* upgrade react-native
*使用守望者watchman watch-del-all
*删除node_modules
* clean cache npm cache clean
或npm start -- --reset-cache
操作:窗口8
react-native-cli:2.0.1
反应原生:0.44.2(也试过0.47.1)
Android:模拟器Nexus5X
提前谢谢大家!
答案 0 :(得分:4)
删除babel-preset-react-native
中的node_modules
文件夹,然后使用npm install babel-preset-react-native@2.1.0 --save-dev
安装此库的旧版本2.1.0。
答案 1 :(得分:3)
如果某人正在使用本机:0.57.1或最新版本,则将babel-preset-react-native替换为metro-react-native-babel-preset。如果在连接到设备时仍然出现500错误,请执行以下步骤,我想一切都会很好
npm add @babel/runtime
npm install
答案 2 :(得分:0)
降级以下内容:
react-native init Project
cd Project
npm uninstall react-native
npm install --save react-native@0.55.4
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native@4.0.0
react-native run-android
答案 3 :(得分:0)
对我来说,它是关于本机版本的。我只安装了新版本的react native“ 0.59.2”,然后将其降级到以前的版本“ 0.55.2”,一切正常。