3

I am trying to create a react-native project using react-native cli. Command I used to create project

  • npx react-native init test

After this if I try to run this app by

  • cd test & npx react-native run-android

But I get this error:

error Android project not found. Are you sure this is a React Native project? If your Android files are located in a non-standard location (e.g. not inside 'android' folder), consider setting project.android.sourceDir option to point to a new location.

I have android, ios folder in root project and node version is 16.15.0

This is my project 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"
  }
}

4 Answers4

2

I was facing the same issue too so i've created a thread on r/reactnative and someone kind provided a solution. Not sure why, but it works for me. The solution is:

  1. delete node_modules
  2. add this to package.json: "resolutions": { "glob": "7.2.0" }
  3. install node_modules with yarn or npm

https://www.reddit.com/r/reactnative/comments/uphynu/hello_there_is_a_new_error_i_guess/

Ma6upa
  • 21
  • 3
1

The issue comes after glob@7.2.2 was released. Follow the following steps and recompile the project.

  1. Clear node_modules
  2. add this to package.json "resolutions": { "glob": "7.2.0" }
  3. Reinstall node_modules with npm install

If this not work try this command

" yarn add glob@7.2.0"

1

Update on the tagged date. I had the same error on a new install. version 0.69.0 had problems finishing the install. Suggestion from github that I install new project with the previous version

npx react-native init ProjectName --version 0.68.2

https://github.com/facebook/react-native/issues/34055

Marshall Fungai
  • 176
  • 1
  • 6
  • 1
    This worked for me! -- But going forward we are supposed to use the 0.69 version to enable Hermes and many other major upgrades: https://reactnative.dev/blog/2022/06/21/version-069 – Jono Tho'ra Aug 20 '22 at 16:39
1

I fixed mine by using cortinico's answer from https://github.com/facebook/react-native/issues/34055#issuecomment-1165887713

The issue is caused by having some globally installed Yarn/NPM packages which is not generally recommended.

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:

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).

Afterwards you can then simply install using:

npx react-native init PROJECT_NAME
Jono Tho'ra
  • 1,476
  • 3
  • 18
  • 28