Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native start giving Invalid regular expression invalid error

I followed following link to get started with react-native

Getting started with react native

I tried to create native app without expo so i as per documentation i followed following command

npm install -g react-native-cli
react-native init AwesomeProject

After run android command

react-native run-android

It gave me following error on emulator

enter image description here

So i used start command to run metro server

react-native start

This command gave me another error in console

enter image description here


2 Answers

There is a problem with Metro using some NPM and Node versions.

You hay 2 alternatives:

  • Alternative 1: Uninstall node and npm and reinstall with another (compatible) version: https://nodejs.org/en/download

  • Alternative 2: Go to a file in your npde_modules folder: \node_modules\metro-config\src\defaults\blacklist.js and change this code:
var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

to this:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Please note that if you run npm install or yarn install you'll need to change the code again.

like image 122
Javier C. Avatar answered Sep 09 '25 03:09

Javier C.


Its compatibility issue of Nodejs I uninstalled my Node(12.11) and installed Node(10) stable version and it worked perfectly.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!