美文网首页
React Native编译错误 Cannot find mod

React Native编译错误 Cannot find mod

作者: an鑫_wolfxin2010 | 来源:发表于2018-08-04 00:27 被阅读0次

最近使用React Native开发项目,本人使用的是指定RN版本0.52.0创建项目,命令如下:
react-native init RNProject --version 0.52.0

但是执行react-native run-ios,启动模拟器后报错信息如下:

Failed to load bundle(http://localhost:8081/index.budle?platfrom=ios&dev=true&minify=false) with error:(/Users/caishenye/Workspace/reactnative/RNProject/index.js:Cannot find module '@bable/core' (While processing preset:"/Users/caishenye/Workspace/reactnative/RNProject/node_modules/babel-preset-react-native/index.js")(null)

通过网上查找解决方法,总结遇到此类问题,希望能对读者有所帮助,步骤如下:

1.删除babel-preset-react-native最新版本,并将其版本退回至3.0.2

npm unstall babel-preset-react-native
npm install --save-dev babel-preset-react-native@^3.0.2

2.重新启用应用

react-native run-ios

总结:
模拟器报错的信息主要是babel编译问题,只要将babel-preset-react-native版本回降至^3.0.2,正常是没有问题的,经个人实测没什么问题!

相关文章

网友评论

      本文标题:React Native编译错误 Cannot find mod

      本文链接:https://www.haomeiwen.com/subject/wcrpvftx.html