error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_module code example
Example 1: error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class.
I don't have metro-config in my project, now what?
I have found that in pretty older project there is no metro-config in node_modules. If it is the case with you, then,
Go to node_modules/metro-bundler/src/blacklist.js
And do the same step as mentioned in other answers, i.e.
Replace
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
with
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
P.S. I faced the same situation in a couple of projects so thought sharing it might help someone.
Edit
As per comment by @beltrone the file might also exist in,
node_modules\metro\src\blacklist.js
Example 2: Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class
To fix the Invalid Regular Expressing while running
react-native start
Go to \node_modules\metro-config\src\defaults\blacklist.js
if metro-config not found
then, go to \node_modules\metro\src\blacklist.js
Replace the SharedBlacklist with the following
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];