Requiring unknown module "498" error in ReactNative getting started example - ios

I'm trying to build and run an iOS simulator version of the getting started React Native project from the instructions at:
https://facebook.github.io/react-native/docs/getting-started.html
The app launches in the XCode simulator, displays it's window very briefly but then an exception occurs that opens a red screen with the message
"Requiring unknown module "498".If you are sure the module is there,
try restarting Metro Bundler. You may also want to run yarn, or npm
install (depending on your environment).
loadModuleImplementation require.js:176:29
viewPropTypes.js:15:30
loadModuleImplementation require.js:212:12
View.js:20:22
loadModuleImplementation require.js:212:12
AppContainer.js:22:13"
etc
Line 15 of ViewPropTypes is
const PlatformViewPropTypes = require('PlatformViewPropTypes');
Line 20 of node_modules/react_native/Libraries/Components/Views/View.js is
const ViewPropTypes = require('ViewPropTypes');
Note: There is another, 15 line View.js files in the directory structure at node_modules/react_native/lib/ it's basically a stub containing
// This is a forwarding module to allow React to require React Native internals
// as node dependency
module.exports = require('View');
I'm on the latest of everything, MacOS High Sierra (10.13.4), XCode 9.3 with 9.3 command line tools installed. I've tried running yarn and npm install, and a fresh install. Obviously I have NPM and Watchman installed. Any ideas why the stock example won't run for me?

Newbie mistake. I had previously attempted to build a different React Native project in a different directory, and Metro Bundler was still pointed at the previous project. As the error message suggested, restarting Metro Bundler fixed the problem.
Also didn't realize the errors in the exception screen were tappable, they take you right into the Metro Bundler terminal process for more detail. Hope this helps someone else too!

In my case, just close all the related process, and re-run react-native run-android solved the problem.
refer to: https://github.com/facebook/react-native/issues/11568

I had the same issue.
In my case, while creating a reusable component, I wasn't importing React into the file,as I was not using them(in functional component) in the component file.
Turns out that jsx to React Element conversion happens per file/module basis, so we should import React and component in every file.
Including Both React and Component normally, solved the problem.

For me I got "955" error. And a simple solution was to
import React, {Component} from "react";

Related

Expo react-native app suddenly stuck on Splash Screen

I've been building my expo app for a few months now - has always been working just fine.
I didn't touch it for 2/3 weeks and now, when I run expo start, my app gets stuck on the Splash Screen.
I managed to connect to react native debugger and I am getting this error:
Error: React Refresh runtime should not be included in the production bundle.
Error: Requiring module "node_modules/react-native/Libraries/Core/InitializeCore.js", which threw an exception: Error: React Refresh runtime should not be included in the production bundle.
Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
app.json and package.json can be found here
Another thing that might be helpful is that my App.tsx code doesn't even get reached (I have a couple of console logs that don't fire).
To anticipate some questions:
I'm not using preventAutoHideAsync(). In fact, I've stripped back the code to just display a single View in App.tsx
I haven't changed a single thing (didn't install new packages or change any code). This exact codebase run just fine two weeks ago
I've tried yarn cache clean, deleting node_modules and running yarn install, deleting .expo and .expo-shared folders, and updating to latest expo-cli version
I've tried running in both a real device and a simulator
Could anyone help diagnose this? Any advice is much appreciated

ios Could not get BatchedBridge, make sure your bundle is packaged properly

I am getting this while running app on simulator using xCode, version 9.2
I've tried other solution mentioned on Stack overflow & Github S1S2 S3 S4 but most of the solution are mentioned for android.
P.S. This project also includes purescript code explained here Integrate Pure Script in your React Native project
That's how I resolved it.
Terminate your metro bundler > react-native link > react-native run-ios
It was not bundling because of some errors which was not showing in the simulator but just this error was thrown.
create index.js, index.android.js and index.ios.js whith the same content. I do have all of them and it solved my issue
I have also faced the same issue when I changed the name of images saved in my local directory. In my case, I have just restarted metro bundler, deleted the app, and restarted the app. Issue was fixed for me.
Try this:
npx react-native-asset
then:
react-native run-ios
This issue is caused basically when some packages or images are not bundled properly, it might be caused because of improper assets path or internet issue when installing packages or reload issue. The expo bundles into a standalone library so it can be available immediately.
This error does not provide any stack to debug since it does not properly have the bundled data even for error stack.
I have just face few bundled scenarios
Scenario 1 => While the expo is running and we install a new library on fly, few times during this importing the library might not get bundled properly, so it's better to stop the expo and re-run, or try reloading the error in app. This will some time resolve the issue, or if there is some error it will show up the error stack
Scenario 2 => You have a customised asset director or have changed the asset path in app.json file improperly.
Please let me know in comments if there are any other scenarios
I had a metro bundler terminal window opened and whenever I was running npm run ios , it wasn't starting a new metro server, the problem was that. I closed the metro bundler terminal window and ran npm run ios and it opened a started a new metro server and the error was gone
I had a same issue, then I did:
rm -rf node_modules,
npm install
and restarted the metro (npm start). It worked.
In Settings, go to Privacy > Local Network to see a list of every app that requested access. I solved by allowing my app to access to the local network. (Trying to run on physical iPhone device from my mac m1 on the same wifi).
Source
Make sure that when you restart the expo project you do so with expo start -c
-c throws out the cache, otherwise the problem persisted for me.

How to install SafeAreaView to my project with react-native version 0.48.0?

Here is the problem:
I want to install SafeAreaView to my project to adapt iPhone X screen, and I do not want to upgrade react-native version to 0.50.1 which contains the SafeAreaView component, now my react-native version is 0.48.0, there is also a JS only version that is available as an npm module, react-native-safe-area-view.
https://github.com/react-community/react-native-safe-area-view
I installed it with
npm install react-native-safe-area-view --save
then I run my project with xcode, It shows errors
Here is the errors:
error: bundling failed: ambiguous resolution: module /Users/dongfanggouwu-xiong/WebstormProjects/untitled/index.js tries to require react-native, but there are several files providing this module. You can delete or fix them:
/Users/dongfanggouwu-xiong/WebstormProjects/untitled/node_modules/react-native-safe-area-view/node_modules/react-native/package.json
/Users/dongfanggouwu-xiong/WebstormProjects/untitled/node_modules/react-native/package.json
there are two react-native module, one is in react-native-safe-area-view, and I don't know how to fix it, I have wasted much time on it, and tried a lot ways to find a solution.
So is there anyone who has the same problem about iPhone X adaption in react-native with me?
Finally, I found a solution.
If you’re not on React Native 0.50+ yet, you can use react-navigation’s SafeAreaView.
import { SafeAreaView } from 'react-navigation'
and the react-navigation version must be the newer version which contains SafeAreaView, as far as i know, react-navigation version has to at least 1.00#beta 16, so maybe you need to upgrade your react-natigation to a newer version.

React-Native: Build error GeneratedInfoPlistDotEnv.h file not found

I had a old React-Native project which I wanted to give it a try again and when trying to run the project on iOS (Android works perfect) I get the error that Debug-iphonesimulator/GeneratedInfoPlistDotEnv.h file not found.
If I run the project from the command react-native run-ios, than the build will succeed.
What can cause this issue and how can it be fixed?
I have tried to fix it with the comments from this issue but no success.
React-Native verision: 0.47
Full error:
<built-in>:1:10: fatal error:
'/Users/myUser/Library/Developer/Xcode/DerivedData/Project-gcaxrvbcwgkfhkadevoqxcprxszw/Build/Products/Debug-iphonesimulator/GeneratedInfoPlistDotEnv.h' file not found
I fixed by copying file GeneratedInfoPlistDotEnv.h (in /ios/build/Build/Products/) to the path mentioned in the error message.
The path mentioned in error message for simulator is not same as real phone, you need to copy for a second time.
The development for React Native just like droped in a deep black hole, what you need to do is just climb and climb and climb...
Changing the Info.plist preprocessor prefix file to works for me ${CONFIGURATION_BUILD_DIR}/../GeneratedInfoPlistDotEnv.h
Image of code in Xcode 9
If you're coming from React version 0.60 and above, you should be referencing the package from GitHub instead of NPM. The author hasn't released auto-linking support on NPM yet, even though it's already merged!?
Try these steps after you unlink and uninstall the existing version of react-native-config. Remember to revert to default Info.plist preprocessor settings in XCode build settings.
yarn add https://github.com/luggit/react-native-config.git
cd ios && pod install
You don't have to add any other post-install scripts, just run the app like usual and it should work fine. Make sure you undo any other fixes before doing this.

Can't require external react native Components

I'm currently trying to learn react Native. While building my first App I tryed to include a external Component from Github (https://github.com/voronianski/react-native-effects-view). Fallowing the small step by step instruction I installed the Component via npm npm install react-native-effects-view --save and included the native Code via XCode:
and required the Component via var EffectsView = require('react-native-effects-view');. After restarting the App I get the fallowing error: Error: Requiring unknown module "react-native-effects-view". If you are sure the module is there, try restarting the packager. (I did restart the package roughly 1000 times)
Maybe somebody can point out the mistake I did and explain me how to do it correct?
Thanks
Daniel
Try to run react-native run-ios. You need to run this after npm install.
you need to bundle your app again since emulator doesn't have the binary for react-native-effects-view module yet
so just run this command again
react-native run-ios

Resources