question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Metro Bundler did not started automatically, blacklist.js has some issue!

See original GitHub issue

React Native version: 0.60

Steps To Reproduce

  1. Create a new react-native project using “npx react-native init NewProject”.
  2. Try to run it using “npx react-native run-android”.

Problems

  1. Metro Bundler Server automatically starts but closes before app launches.
  2. When we try to launch metro bundler manually, then it shows following error: error Invalid regular expression: /(.\fixtures.|node_modules[]react[]dist[].|website\node_modules.|heapCapture\bundle.js|.\tests.)$/: Unterminated character class. Run CLI with --verbose flag for more details. SyntaxError: Invalid regular expression: /(.\fixtures.|node_modules[]react[]dist[].|website\node_modules.|heapCapture\bundle.js|.\tests.)$/: Unterminated character class at new RegExp () at blacklist (D:\projects\new_proj\node_modules\metro-config\src\defaults\blacklist.js:34:10) at getBlacklistRE (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\tools\loadMetroConfig.js:69:59) at getDefaultConfig (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\tools\loadMetroConfig.js:85:20) at load (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\tools\loadMetroConfig.js:121:25) at Object.runServer [as func] (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\commands\server\runServer.js:82:58) at Command.handleAction (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js:160:21) at Command.listener (D:\projects\new_proj\node_modules\commander\index.js:315:8) at Command.emit (events.js:210:5) at Command.parseArgs (D:\projects\new_proj\node_modules\commander\index.js:651:12)

Solution

Change the content of \node_modules\metro-config\src\defaults\blacklist.js file by following : 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/./ ];

Result

Finally, project runs successfully! But need to have a permanent solution.

Please read the detailed solution in comments.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ikayzcommented, Dec 3, 2019

@tusharojha thanks man, you are a lifesaver your solution worked. I searched Stackoverflow and countless websites with no avail. Though I’d have to add that line to every project, it’s temporary. The React Native team need to fix this issue ASAP.

1reaction
ikayzcommented, Dec 3, 2019

@tusharojha I make it exactly like your screenshot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactNative Metro Bundler not starting automatically
When I ran yarn android the metro bundler successfully runs in a separate terminal and app runs with no issue.
Read more >
react native metro bundler not starting : Solved Solution
Recently a lot of programmers are having issue on using a react native init application to start an app all because of a...
Read more >
Configuring Metro - Meta Open Source
A Metro config can be created in these three ways (ordered by priority):. metro.config.js; metro.config.json; The metro field in package.json.
Read more >
Troubleshooting - React Native
The Metro bundler runs on port 8081. If another process is already using that port, you can either terminate that process, or change...
Read more >
Metro bundler closing after running react-native run-android
then you have to create a shell file (.sh file), where you will tell the system to change the file path of “blacklist.js”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found