Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 211
SafeFastExpressive Avatar asked Apr 04 '18 20:04

SafeFastExpressive


2 Answers

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!

like image 184
SafeFastExpressive Avatar answered Sep 24 '22 01:09

SafeFastExpressive


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

like image 34
Siwei Avatar answered Sep 26 '22 01:09

Siwei