I am getting Invalid regular expression error while running npm start

Viewed 15415

I have recently installed the expo. I have created a project using expo init. After creation when I running npm start I am getting below error please slove my issue

> @ start C:\Users\ujwal\Desktop\Java\my-new-project
> expo start

Starting project at C:\Users\ujwal\Desktop\Java\my-new-project
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.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ujwal\AppData\Roaming\npm-cache\_logs\2019-10-07T11_19_27_567Z-debug.log
4 Answers

you have to make change in this file {project_root}\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__\/.*/
];

hope it'll helps you....

It seems like you are experiencing this error: https://github.com/facebook/react-native/issues/26598. Per the issue ticket, you have some alternatives:

First option: downgrade to node 10.16.3 LTS

Second option: if you use Yarn, add a 'resolutions' property to your package.json to point to the metro-config version where the issue is fixed:

  "resolutions": {
    "metro-config": "0.57.0"
  },

Third option: if you use npm instead of yarn, you need to find a way to fix the "metro-config" sub-dependency to "0.57.0". I don't know how to do that, maybe npm-shrinkwrap can help you.

Using react (and not react-native) on Windows, got the same issue. Fixed it with a newer version of node.

I had this same issue today after installing a new expo-template-tabs project and then running expo start.

You will need to make change in the file:

{project_root}\node_modules\metro-config\src\defaults\blacklist.js

There is an invalid regular expression that needed to be changed. So please change this:

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

As seen on this answer provided by Kishan Gujarati.

Related