8

Does anyone experience this issue? After pointing to the default page in index.js, an error occurred with the following error code:

Requiring unknown module "1". If you are sure the module exist, try restarting Metro.

The screenshot: enter image description here

And here's the exact code from index.js:

import {AppRegistry} from 'react-native';
import App from './src/components/LoginPage';`// import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

enter image description here

And my landing page: enter image description here

Vic Andam
  • 823
  • 2
  • 7
  • 17
  • 1
    Do any of the answers here help you? In my case it was finding the process running on the required port, as Yun Li suggests. https://stackoverflow.com/questions/51093932/requiring-unknown-module-11-error-on-ios-simulator – ryanwebjackson May 14 '20 at 02:56

7 Answers7

8

Found the answer here Basically it asks you to terminate the processes running on a specific port.

Run the following command to find the id for the process that is listening on port 8081:

$ sudo lsof -i :8081

Then run the following to terminate the process:

$ kill -9 <PID> 
Mostafa Sultan
  • 2,268
  • 2
  • 20
  • 36
3

Try to remove 'node_modules' folder and re-install modules with yarn or npm install

I hope it's can help you

0

This is my solution. It works for me. go through the following steps. check the emulator or your device reloading at each of the steps whether it is work or not.

  1. wipe out your emulator or delete the app from your device and run it again.
  2. run nmp install in your terminal and then restart metro bundler by running react-native start.
  3. run your app in react native CLI -> npx react-native run-android or in expo CLI -> expo start.

cheers!

0

This problem can be faced from multiple sources. The one I faced was with Stack Navigation I used in my case. It was use of 'react-native-gesture-handler' and 'react-native-reanimated' here. For that we need to do 2 things without fail -

  • Adding import 'react-native-gesture-handler'; as the very first line in wither index.js or App.js which ever present in code.
  • Adding plugins: ['react-native-reanimated/plugin'], in bable.config.js along with presets there.
pjoshi
  • 249
  • 3
  • 7
0

try npx react-native run-android or react-native run-ios to rebuild and install app.

haoxiqiang
  • 359
  • 2
  • 4
0

TLDR: If you are using yarn, switch to npm.

I used yarn before and used to get this error at almost every change I did to the app. I have used npm on other projects without having these headaches so decided to switch back to npm just to try and it worked. I still get the error when I introduce bigger changes to the app like reorganizing navigation or installing new packages, but that's it.

-1

Just close the server and open it again That solved to me