问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/59567538/invalid-regular-expression-error-after-running-expo-start-command