React-native: Question: getting error on 'react-native start'

Created on 26 Sep 2019  路  12Comments  路  Source: facebook/react-native

Hi,
1. I just installed node.js & cli
- * installed node.js

npm -g react-native-cli

  1. And created a 'new project'.

    react-native init new_project

  2. and inside that 'new_project' directory, I tired to see if metro bundler works well.

    react-native start

But the command gives me following error and metro is not starting.
Any clue for fixing this error?
(I'm using windows 10 OS.)

------------------error message I am getting----------------------
C:\projects\new_proj>react-native start
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_projnode_modules\metro-config\src\defaults\blacklist.js:34:10)
at getBlacklistRE (D:\projects\new_projnode_modules\react-nativenode_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:69:59)
at getDefaultConfig (D:\projects\new_projnode_modules\react-nativenode_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:85:20)
at load (D:\projects\new_projnode_modules\react-nativenode_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:121:25)
at Object.runServer [as func] (D:\projects\new_projnode_modules\react-nativenode_modules\@react-native-community\cli\build\commands\server\runServer.js:82:58)
at Command.handleAction (D:\projects\new_projnode_modules\react-nativenode_modules\@react-native-community\cli\build\cliEntry.js:160:21)
at Command.listener (D:\projects\new_projnode_modules\commander\index.js:315:8)
at Command.emit (events.js:210:5)
at Command.parseArgs (D:\projects\new_projnode_modules\commander\index.js:651:12)

Ran Commands Question

Most helpful comment

Go to your Project Foldernode_modules\metro-config\src\defaults\blacklist

Get the changes from attached file:
blacklist.txt

UPDATE
I noticed that the editor here removes the (*) from the code, so I attached a file containing the code.
It works fine now

All 12 comments


We are automatically closing this issue because it does not appear to follow any of the provided issue templates.

馃憠 Click here if you want to report a reproducible bug or regression in React Native.

It's caused by node v12.11.0, downgrade to v12.10.0 will solve it.

Yes, maybe it's a bug in the latest v12.11.0 node, see https://stackoverflow.com/questions/58120990/question-getting-error-on-react-native-start# for more details.

O mesmo estava acontecendo comigo, fiz o downgrade do node e funcionou.

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__\/./
];

Yes, it is the bug in the newer version of node.js.

It appears in node_modules\metro-config\src\defaults\blacklist.js, there is an invalid regular expression that needed to be 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__\/./
];

Source: https://stackoverflow.com/questions/58120990/question-getting-error-on-react-native-start/58122821#58122821

Go to your Project Foldernode_modules\metro-config\src\defaults\blacklist

Get the changes from attached file:
blacklist.txt

UPDATE
I noticed that the editor here removes the (*) from the code, so I attached a file containing the code.
It works fine now

i had the same issue its work fine for me

V谩 para a pasta do projeto \ node_modules \ metro-config \ src \ defaults \ blacklist

Obtenha as altera莽玫es do arquivo anexado:
blacklist.txt

ATUALIZA脟脙O
Observei que o editor aqui remove o (*) do c贸digo, ent茫o anexei um arquivo que cont茅m o c贸digo.
Funciona bem agora

very good it works

Thank you; MagedYaseen; Works perfectly : )

  • Go to node_modules/metro-config/src/defaults/blacklist.js
  • Replace your var sharedBlacklist to this

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

Was this page helpful?
0 / 5 - 0 ratings