How to resolve the error on 'react-native start' How to resolve the error on 'react-native start' reactjs reactjs

How to resolve the error on 'react-native start'


I just got a similar error for the first time today. It appears in \node_modules\metro-config\src\defaults\blacklist.js, there is an invalid regular expression that needed changed. I changed the first expression under sharedBlacklist from:

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

to:

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


This is caused by node v12.11.0 due to the way it deals regular location there two ways to solve this problem

Method I

You can downgrade to node v12.10.0 this will apply the correct way to deal with parsing error

Method II

You can correctly terminate the regular expression in you case by changing the file located a:

\node_modules\metro-config\src\defaults\blacklist.js

From:

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

To:

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


[Quick Answer]

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

You can fix the problem changing some code in the file \node_modules\metro-config\src\defaults\blacklist.js .

Search this variable:

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

and change to this:

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

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