[英]react-native android project not found error
I am trying to create a react-native project using react-native cli.我正在尝试使用 react-native cli 创建一个 react-native 项目。 Command I used to create project
我用来创建项目的命令
After this if I try to run this app by在此之后,如果我尝试通过以下方式运行此应用程序
But I get this error:但我得到这个错误:
error Android project not found.找不到错误 Android 项目。 Are you sure this is a React Native project?
你确定这是一个 React Native 项目吗? If your Android files are located in a non-standard location (eg not inside 'android' folder), consider setting
project.android.sourceDir
option to point to a new location.如果您的 Android 文件位于非标准位置(例如不在“android”文件夹内),请考虑将
project.android.sourceDir
选项设置为指向新位置。
I have android, ios folder in root project and node version is 16.15.0我在根项目中有 android, ios 文件夹,节点版本为 16.15.0
This is my project json:这是我的项目 json:
{ "name": "test", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint." }, "dependencies": { "react": "17.0.2", "react-native": "0.68.2" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "^7.32.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.67.0", "react-test-renderer": "17.0.2" }, "jest": { "preset": "react-native" } }
I was facing the same issue too so i've created a thread on r/reactnative and someone kind provided a solution.我也面临同样的问题,所以我在 r/reactnative 上创建了一个线程,并且有人提供了解决方案。 Not sure why, but it works for me.
不知道为什么,但它对我有用。 The solution is:
解决方案是:
https://www.reddit.com/r/reactnative/comments/uphynu/hello_there_is_a_new_error_i_guess/ https://www.reddit.com/r/reactnative/comments/uphynu/hello_there_is_a_new_error_i_guess/
The issue comes after glob@7.2.2 was released.这个问题是在 glob@7.2.2 发布之后出现的。 Follow the following steps and recompile the project.
按照以下步骤重新编译项目。
If this not work try this command如果这不起作用,请尝试此命令
" yarn add glob@7.2.0" “纱线添加 glob@7.2.0”
Update on the tagged date.更新标记日期。 I had the same error on a new install.
我在新安装时遇到了同样的错误。 version 0.69.0 had problems finishing the install.
0.69.0 版在完成安装时出现问题。 Suggestion from github that I install new project with the previous version
github 建议我用以前的版本安装新项目
npx react-native init ProjectName --version 0.68.2
https://github.com/facebook/react-native/issues/34055 https://github.com/facebook/react-native/issues/34055
I fixed mine by using cortinico's answer from https://github.com/facebook/react-native/issues/34055#issuecomment-1165887713我通过使用来自https://github.com/facebook/react-native/issues/34055#issuecomment-1165887713的 cortinico 的回答修复了我的问题
The issue is caused by having some globally installed Yarn/NPM packages which is not generally recommended.该问题是由于全局安装了一些通常不推荐的 Yarn/NPM 包引起的。
Depending on the commands you installed in the past with -g, you should be able to cleanup your environment with a combination of those commands:根据您过去使用 -g 安装的命令,您应该能够使用这些命令的组合来清理您的环境:
yarn global remove react-native
yarn global remove react-native-cli
npm uninstall -g react-native
npm uninstall -g react-native-cli
Make sure the global packages are clean with:确保全局包是干净的:
yarn global list
npm -g list
(check that nothing react-native related is available in those lists). (检查这些列表中是否没有与 react-native 相关的内容)。
Afterwards you can then simply install using:之后,您可以使用以下命令简单地安装:
npx react-native init PROJECT_NAME
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.