116

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"

Mateo Guzmán
  • 1,031
  • 1
  • 11
  • 24
Asad
  • 2,760
  • 7
  • 18
  • 56

30 Answers30

181

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

Brijesh Shiroya
  • 3,272
  • 1
  • 12
  • 18
  • 4
    @BrijeshShiroya I am trying to convert react-native project from expo to CLI. I did everything what you said, but still getting same problem. I tried every answer I found relative to this question. But nothing helped me. – Avijit Barua Nov 08 '18 at 06:28
  • @AhmadDehnavi If my answer is realy helpful to you then upvote it, so other can also get help. – Brijesh Shiroya Jun 24 '19 at 15:03
  • for windows type- TASKKILL /IM node.exe, or you can simply remove .expo folder – Qbert Apr 09 '20 at 03:21
41

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

npm start -- --reset-cache
Chetan J Rao
  • 807
  • 9
  • 14
9
react-native start --reset-cacher
Nimantha
  • 5,793
  • 5
  • 23
  • 56
6

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

Chiamaka Nwolisa
  • 921
  • 6
  • 15
4

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
t.ios
  • 836
  • 9
  • 16
3

Close the current Metro Bundler and restart by typing the comment:

npm start -- --reset-cache
Nimantha
  • 5,793
  • 5
  • 23
  • 56
Socheat Yorn
  • 67
  • 1
  • 2
3

Stop the node server running and run 'react-native run-ios' once again.

Nimantha
  • 5,793
  • 5
  • 23
  • 56
cherucole
  • 495
  • 7
  • 14
3

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.

Jose
  • 1,283
  • 16
  • 19
  • 1
    `error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening coreApp.xcworkspace.` This dev environment is such a nightmare. – velkoon Aug 05 '21 at 19:32
2

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

Nimantha
  • 5,793
  • 5
  • 23
  • 56
sahu
  • 1,140
  • 9
  • 19
2

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.

Nimantha
  • 5,793
  • 5
  • 23
  • 56
Zhengqian Kuang
  • 939
  • 1
  • 8
  • 11
1

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

Asad
  • 2,760
  • 7
  • 18
  • 56
1

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

Siraj Alam
  • 7,620
  • 6
  • 46
  • 63
1
  1. Close Emülator

  2. npm start -- --reset-cache

  3. XCode -> Product -> Clean Build Folder

  4. npx react-native run-ios

Nimantha
  • 5,793
  • 5
  • 23
  • 56
1

I tried killall -9 node command in terminal

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

Lakshya Tyagi
  • 69
  • 1
  • 4
1

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.

Nimantha
  • 5,793
  • 5
  • 23
  • 56
velkoon
  • 765
  • 1
  • 12
  • 32
0

Need to replace

.setJSMainModulePath("index") with .setJSMainModulePath("index.android")
Aristo Michael
  • 2,138
  • 3
  • 32
  • 43
0

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

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

Filip Savic
  • 2,268
  • 23
  • 25
0

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 !

Ruben Mim
  • 66
  • 1
  • 4
0

If your are building a new npm module and this rely on some other dependencies already added in your project, you need to add those dependencies in the package.json of the npm package as peer dependency.

package.json

"peerDependencies":{
 "@org/your-dependency":">= 1.2.0"
}
[Tue Aug 31 2021 17:57:45.731]  ERROR    Error: Type oid already present, js engine: hermes
[Tue Aug 31 2021 17:57:45.732]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
[Tue Aug 31 2021 17:57:45.732]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
Ivan Cabrera
  • 221
  • 4
  • 8
0

For me, the issue was starting the metro bundler when there was an error in one of my styles. I had an error in my code from last night, and then my computer did a restart overnight. Trying to start everything up today resulted in this error along with Invariant Violation: Invalid prop 'position' of value 'fixed' supplied to. Fixing the position value resolved both errors.

John Harding
  • 441
  • 6
  • 13
0

One single error but there might be multiple causes. Seeing a lot of diverse discussions in the community means this issue could be hard to find. Try to proceed with the following.

  1. There might be a missing import.
  2. There might be a missing configuration with the library you recently installed.
  3. You may not receive errors in Android but in IOS. Then one of the lib configurations in IOS is missing.
  4. Your cache needs to be reset if RN is upgraded.

If you still cannot find the issue with the above, remove some imports or screens from your App.js. Going with this you can find what exactly caused this error. This is how I found my issue after a day of research.

Click to see further Github issues

Sabri Meviş
  • 2,011
  • 1
  • 29
  • 32
0

closing your current metro bundle and run this :--

npm start -- --reset-cache
Tyler2P
  • 2,182
  • 12
  • 17
  • 28
Mithpans
  • 31
  • 4
-1

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.

Harry B
  • 2,686
  • 1
  • 20
  • 41
  • I'm sure other solutions will work for some. For me a restart was the only solution I could find. Hardly drastic vs spending hours trying to debug. It's just one option. – Harry B Aug 29 '18 at 08:34
-1

This happens for one of these reasons:-

  • Either, your app's entry file 'index.js' is corrupt due to syntax error or your React App could not load.
  • Your Metro Bundler instance running is stale and corrupt.

Solution

  • Terminate already running Metro Bundler instance

  • Reset Cache

    react-native start --reset-cache
    
  • Delete android/app/bulid folder

  • Start server again

illusionist
  • 9,926
  • 2
  • 59
  • 77
-1

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
-1

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..
oguz ismail
  • 39,105
  • 12
  • 41
  • 62
-1

npm start -- --reset-cache

react-native run-ios

works for me.

Menon Hasan
  • 877
  • 9
  • 13
-2
import { AppRegistry } from 'react-native';

AppRegistry.registerComponent('your app name',  () => point);
Suraj Rao
  • 28,850
  • 10
  • 94
  • 99
-2

You just need to close the metro server by control + c and then restart by npm start --reset-cache

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

Nimantha
  • 5,793
  • 5
  • 23
  • 56
  • It did not "definitely" work after a restart either. Nor after following every other suggestion here. – velkoon Aug 05 '21 at 19:15