npm 运行expo start命令后出现无效正则表达式错误

mitkmikd  于 2022-12-13  发布在  其他
关注(0)|答案(2)|浏览(162)

I am new to React native development. After running:

expo start

or

npm start

or

yarn start

It returns the following error message:

Invalid regular expression error

How can I debug this?

PS C:\Users\Admin\Desktop\React Course\New folder (2)\newproject> **expo start**
Starting project at C:\Users\Admin\Desktop\React Course\New folder (2)\newproject
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
**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 (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\metro-config\src\defaults\blacklist.js:34:10)
    at getBlacklistRE (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:66:59)
    at getDefaultConfig (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:82:20)
    at load (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:118:25)
    at Object.runServer [as func] (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\@react-native-community\cli\build\commands\server\runServer.js:82:58)
    at Command.handleAction (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\@react-native-community\cli\build\index.js:164:23)
    at Command.listener (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:210:5)
    at Command.parseArgs (C:\Users\Admin\Desktop\React Course\New folder (2)\newproject\node_modules\commander\index.js:651:12)
Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
fhity93d

fhity93d1#

In order to fix this problem, Go to

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

Change

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

Check this for more information.

u0njafvf

u0njafvf2#

For anyone unable to find \metro-config, I found the file under

node_modules\metro\src\blacklist.js

and made the same changes as listed above:

/node_modules[/\\]react[/\\]dist[/\\].*/,

to

/node_modules[\/\\]react[\/\\]dist[\/\\].*/,

相关问题