Cannot find entry file index.ios.js [index.android.js] in any of the roots
网上一搜出现这个问题的人还挺多,解决方法就是:
项目路径下运行:npm start -- -reset-cache
再重新启动项目:react-native run-ios(run-android)
如果还是失败那么就在这里看看有没有解决方案
NPM modules get required from /Users/node_modules/ instead of the project directory
同样的我还遇到了这个问题,就是node_modules
里面的所有依赖文件目录都变成了/users/
这种形式,解决方法:
- 删除 node_modules:rm -rf node_modules && npm install
- 清空watchman: watchman watch-del-all
- npm cache clean && npm install
如果还是失败那么就在这里看看有没有解决方案
如果还是解决不了,那么我猜你是不是用了cnpm install 而不是npm install?
或者说你用的是npm install ?
这两种安装方式都可能会导致问题,特别是cnpm!!在这里千万不能用。
推荐用的方式是:yarn
给npm设置淘宝镜像:
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
安装yarn: npm install yarn -g
给yarn设置淘宝镜像:
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
重新使用命令yarn
代替npm install
,然后重新启动RN项目,应该就不会报错了。
ReactComponentTreeHook.purgeUnmountedComponents is not a function
其实如果报了这个错,估计你安装依赖的时候已经看到了一句警告:react-native@0.48.4" has incorrect peer dependency "react@16.0.0-alpha.12".
但是被你忽略了,解决方法就是修改你现在安装的react版本为提示的版本:
yarn add react@16.0.0-alpha.12
No bundle URL present. Make sure you’re running a packager server or have included a .jsbundle file in your application bundle.
这个错误是模拟器红屏弹出的错误信息:
Xcode或者命令行提示的错误是:third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: ‘config.h’ file not found,搜了一下解决办法:
删除
ios/build
路径,然后重新react-native run-ios
没有用,接着第二种办法:
删除
node_modules/third-party
,然后重新react-native run-ios
但是我的node_modules
下根本没有这个插件,所以我用了最简单粗暴的方法:删除整个node_modules
目录,然后重新使用yarn
命令安装,最后解决了。