96
votes

I am using native base for making app in react-native. I am new to both things. When I run the app It gives me this error:

enter image description here

Here is my code:

export default class Point extends Component {

    render() {
        return (
            <Container>
                <Header>
                    <Left>
                        <Button transparent>
                            <Icon name='menu' />
                        </Button>
                    </Left>
                    <Body>
                        <Title>Header</Title>
                    </Body>
                    <Right />
                </Header>
            </Container>
        );
    }
}

Here is the screenshot of my versions

enter image description here

and nativebase version is "native-base": "^2.1.2"

28
Share code of index.ios.js. Also check if any other packager is running - Supriya Kalghatgi
This has to be the question with the most repeated answer - Taylor A. Leach
Seeing to AppRegistry.js, there are lots of errors because typeScript support is not there. Is this the reason of the error? Have I to include support for typescript? - Abhinav Saxena

28 Answers

160
votes

Just kill all node process and start npm server and run application:

Step1: run command killall -9 node

For windows users, run: taskkill /im node.exe

Run taskkill /f /im node.exe if the process still persists.

Step2: run command npm start --reset-cache

Step3: run command react-native run-ios OR react-native run-android

34
votes

Closing the current Metro Bundler and restarting by resetting the cache worked for me

npm start -- --reset-cache
9
votes

simply run below command.

react-native start --reset-cache

6
votes

You should have this at the bottom of the index.ios.js file AppRegistry.registerComponent('Point', () => Point); and also import AppRegistry from react-native

4
votes

I had this issue - it was odd because I reset my repo to a time when the app was working. The issue was with my simulator (iOS).

For me the solution was to

  1. kill the simulator program (quit)
  2. then - close the terminal window that is opened when simulator is ran (Metro Bundler) Image of my terminal window
3
votes

I have solved it, just closing the current Metro Bundler and restarting by type comment below.

npm start -- --reset-cache
3
votes

What worked for me was to just stop the node server running and run 'react-native run-ios' once again

2
votes

Worked for me for below version and on iOS

 "react": "16.9.0",
 "react-native": "0.61.5",

Step to resolve Close the current running Metro Bundler Try Re-run your Metro Bundler and check if this issue persists

Hope this will help !

2
votes

In my case, trying npm start -- --reset-cache and getting a bunch more errors, I deleted (uninstalled) the app from iOS and Android and yarn ios yarn android did the trick. (If this does not work for you, please kindly DO NOT give me a thumb down. Encourage people to speak, do not discourage them.)

1
votes

Just closing the metro bundler and rebuilding the app done my job.

1
votes

1.Close Emülator

2.npm start -- --reset-cache

3.XCode -> Product -> Clean Build Folder

4.npx react-native run-ios

1
votes

I tried killall -9 node command in terminal

then again i run my project using npm start and it's working fine

0
votes

I was using native base for my app here is link native base

and you can see there is no app registry like this

 AppRegistry.registerComponent('Point', () => Point) 

but i have to do this to run my app

0
votes

Need to replace

.setJSMainModulePath("index") with .setJSMainModulePath("index.android")
0
votes

For me, restarting my computer appears to be enough to clear this issue.

It's often required after I've switched between branches, or merged branches using git.

0
votes
import { AppRegistry } from 'react-native';

AppRegistry.registerComponent('your app name',  () => point);
0
votes

If you are using windows and running yarn open cmd on admin mode' terminate and Restart the node process by typing this command.

Find the node: killall -9 node force to kill : taskkill /f /im node.exe Reset the cache : yarn start --reset-cache

Navigate to your project directory: cd myapp Re-Run your App : yarn android

0
votes

you just need to close the metro server by control + c and then restart by npm start

Note: If that too doesn't work then just restart your computer, it'll definitely work then.

0
votes

In my case, I didn't import a module in a component that I was using it in.

So, just check if you are importing the module you want to use...

0
votes

One of the libraries has not been linked. To check, just comment out in the package.json one by one the latest libraries added.

yarn remove libraryName.

Then run the app with xcode and puf !

0
votes

The solution is very simple just kill all the running nodes and restart your node server and rebuild your native application and it works.

For Linix:

killall -9 node

For Windows:

taskkill /im node.exe

For Android native App:

react-native run-android 

For IOS native App:

react-native run-ios

Then finally,

npm start
0
votes

I was also suffering from the same error for windows OS. I resolved this by cleaning gradlew.

The steps are:

  1. cd android
  2. gradlew clean
  3. cd..
0
votes

I tend to get this error after I install a new package that has some native code that needs to be installed with it. Usually packages will say install npm module and then install native code via a pod install (ios specific) and after this my app usually throws this error.

In order to get rid of this error I delete and reinstall node_modules and pods since I am making an iOS app and then I also delete the build folder under ios. After that I run the packager with npm start -- --reset-cache and build my app again using the react-native run-ios command. This fixes the issue for me.

0
votes

I ended up creating an entirely new react-native project after a computer restart and after the deletion/rebuild of the npm_modules folder, Pods folder, and my ios build folder did not work. (Quitting the Simulator, Quitting the Terminal app, Quitting XCode, cleaning the project folder in XCode, and running killall -9 node, npm start -- reset-cahce & npm start -- --reset-cache did not work, either). After installing all my packages, I copied and pasted my code from my old project to the new one. Same error. So then I started backtracking my most recent code changes, step by step. After reverting my most recent code changes, it worked. While adding new code little by little, I got an error telling me I forgot to import {StyleSheet} from 'react-native';. I imported that, then continued adding my code that had previously led to the error (which was simply a react-native-elements Button and a StyleSheet const styles). All went well.

So, in the end, my only theory is that I had added too much code at once, and instead of telling me I forgot to import {StyleSheet} like it should have, it instead threw me a vague and infuriating module AppRegistry error. I expect this to get downvoted because I imagine it's beyond-niche and is likely not anyone else's issue. But for the 1 soul out there who this might help save 5 hours of their day (like I spent), I'll post it here...

-1
votes

I am using Expo

In my case, I resolved the issue by adding the following code in app.json file

"expo":{
  ...
  "android": {
    "package": "com.mycompanyname.myappname
  }
}
-1
votes

Simply Restart Your Code Editor.

-2
votes

Ok guys, here we are my solution for this issue:

  • npm install native-base@latest -g

  • npm install react-native@latest -g

  • change package.json for these dependencies

  • delete node_modules and npm install

  • Open it Xcode and Build/Run from scratch

I hope it helped

-2
votes

Deleting node_modules and reinstalling it fixed the error(or at least gave me more specific ones)