Metro Bundler did not started automatically, blacklist.js has some issue!
See original GitHub issueReact Native version: 0.60
Steps To Reproduce
- Create a new react-native project using “npx react-native init NewProject”.
- Try to run it using “npx react-native run-android”.
Problems
- Metro Bundler Server automatically starts but closes before app launches.
- 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:
- Created 4 years ago
- Comments:11 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@tusharojha I make it exactly like your screenshot.