Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Module not found @react-native-community-cli

Tags:

react-native

Project was working fine before I had to reinstall everything on my computer. I get the following error after I run npm install and then expo start

internal/modules/cjs/loader.js:296
      throw err;
      ^

Error: Cannot find module '/home/amber/Documents/GitKraken/school-notification-1/App/node_modules/@react-native-community/cli/build/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:288:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:515:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:759:27)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (/home/amber/Documents/GitKraken/school-notification-1/App/node_modules/react-native/local-cli/cli.js:12:11)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/home/amber/Documents/GitKraken/school-notification-1/App/node_modules/@react-native-community/cli/package.json',
  requestPath: '@react-native-community/cli'
}

Metro Bundler process exited with code 1

This is my package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest --watchAll"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^10.0.3",
    "@react-navigation/web": "^1.0.0-alpha.9",
    "axios": "^0.19.0",
    "expo": "^34.0.1",
    "expo-asset": "^6.0.0",
    "expo-constants": "^6.0.0",
    "expo-font": "~6.0.0",
    "expo-web-browser": "6.0.0",
    "navigationbar-react-native": "0.0.5",
    "qs": "^6.8.0",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
    "react-native-action-button": "^2.8.5",
    "react-native-anchor-carousel": "^3.1.1",
    "react-native-app-intro-slider": "^3.0.0",
    "react-native-calendars": "^1.210.0",
    "react-native-circle-drawer": "^1.0.0",
    "react-native-drawer-menu": "^0.2.5",
    "react-native-elements": "^1.1.0",
    "react-native-gesture-handler": "^1.3.0",
    "react-native-global-props": "^1.1.5",
    "react-native-htmlview": "^0.15.0",
    "react-native-loading-spinner-overlay": "^1.0.1",
    "react-native-popup-dialog": "^0.18.3",
    "react-native-side-drawer": "^1.1.11",
    "react-native-side-menu": "^1.1.3",
    "react-native-sidebar": "^0.3.0",
    "react-native-web": "^0.11.4",
    "react-navigation": "^3.11.0"
  },
  "devDependencies": {
    "babel-preset-expo": "^6.0.0",
    "jest-expo": "^34.0.0"
  },
  "private": true
}
like image 213
Amberyo Avatar asked Sep 10 '19 05:09

Amberyo


3 Answers

Install this package.

npm i @react-native-community/cli
like image 136
manish sasmal Avatar answered Nov 05 '22 20:11

manish sasmal


use npm install @react-native-community-cli and run again, otherwise delete the package-lock.json and node_modules ,install npm again and please clean first before run the project

like image 3
Sumit Kumar Avatar answered Nov 05 '22 20:11

Sumit Kumar


Deleted package-lock.json and node_modules, and then reran npm install and it works fine now.

like image 1
Amberyo Avatar answered Nov 05 '22 19:11

Amberyo